[Python-checkins] TRUNK IS UNFROZEN, available for 2.6 work if you are so inclined

Nick Coghlan ncoghlan at gmail.com
Fri Aug 18 18:41:01 CEST 2006


Georg Brandl wrote:
> Is the following fix for #1541682 okay?
>> Georg
>> Index: Doc/api/intro.tex
> ===================================================================
> --- Doc/api/intro.tex (Revision 51336)
> +++ Doc/api/intro.tex (Arbeitskopie)
> @@ -276,8 +276,12 @@
> if (n < 0)
> return -1;
> for (i = 0; i < n; i++) {
> - if (PyObject_SetItem(target, i, item) < 0)
> + PyObject *index = PyInt_FromLong(i);
> + if (!index)
> return -1;
> + if (PyObject_SetItem(target, index, item) < 0)
> + return -1;
> + Py_DECREF(index);
> }
> return 0;
> }

1. Why not simply change the code to call PySequence_SetItem instead of 
creating a Python integer from the C long which PyObject_SetItem will simply 
have to convert back to a C long anyway?
2. This example code needs to change to use Py_ssize_t instead of int to hold 
i and n (the same goes for other examples on this page, actually...).
Cheers,
Nick.
-- 
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
 http://www.boredomandlaziness.org


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /