PyArg_ParseTuple() & Py_DECREF()

Fredrik Lundh effbot at telia.com
Sat Mar 4 08:16:54 EST 2000


Ralf wrote:
> Consider the following two lines of source code at the
> beginning of a C extension function:
>
>   PyObject *O;
>   if (! PyArg_ParseTuple(args, "O", &O)) return NULL;
>
> Is it necessary to call Py_DECREF(O) before leaving the
> extension function?

no.  PyArg_ParseTuple returns borrowed references.

(releasing references you don't own is a great way
to get into serious trouble...)

</F>





More information about the Python-list mailing list