[Python-checkins] TRUNK IS UNFROZEN, available for 2.6 work if you are so inclined
Georg Brandl
g.brandl at gmx.net
Fri Aug 18 18:49:03 CEST 2006
Nick Coghlan wrote:
> 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?
Because this example is after a paragraph that explicitly mentions
PyObject_SetItem. It could, however be changed to mention PySequence_SetItem,
I think...
Georg
> 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.
>
More information about the Python-checkins
mailing list