Awkwardness of C API for making tuples

Steve Holden steve at holdenweb.com
Thu Feb 3 07:45:22 EST 2005


Fredrik Lundh wrote:

> Dave Cole wrote:
> 
> 
>>    for (i = 0; i < num_values; i++) {
>>PyObject *obj;
>>
>>obj = PyInt_FromLong(value[i]);
>>if (obj == NULL
>>            || PyTuple_SetItem(tuple, i, obj) != 0) {
>>    Py_DECREF(tuple);
>>    return NULL;
>>}
>>    }
> 
> 
> in theory, if PyInt_FromLong succeeds, and PyTuple_SetItem fails, you'll leak
> an object.
> 
> </F> 
> 
> 
> 
And in practice this will only happen during a period when you are 
relying critically on it *not* to ...

regards
  Steve
-- 
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005                      http://www.pycon.org/
Steve Holden                           http://www.holdenweb.com/



More information about the Python-list mailing list