Awkwardness of C API for making tuples

Fredrik Lundh fredrik at pythonware.com
Thu Feb 3 02:41:57 EST 2005


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> 






More information about the Python-list mailing list