[Python-Dev] Py_DECREF(m) on PyInit_xxx() failure? (original) (raw)
Victor Stinner victor.stinner at gmail.com
Thu Nov 30 10:42:50 EST 2017
- Previous message (by thread): [Python-Dev] PEPs: ``.. code:: python`` or ``::`` (syntax highlighting)
- Next message (by thread): [Python-Dev] Py_DECREF(m) on PyInit_xxx() failure?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
CPython has many C extensions with non-trivial PyInit_xxx() functions which has to handle failures. A few modules use "Py_DECREF(m); retutrn NULL;", but most functions only do "return NULL;". Is it a reference leak or not?
Example from Modules/posixmodule.c:
v = convertenviron();
Py_XINCREF(v);
if (v == NULL || PyModule_AddObject(m, "environ", v) != 0)
return NULL;
Py_DECREF(v);
Does this code leak a reference on m? ... Oh, and maybe also leaks a reference on v?
Victor
- Previous message (by thread): [Python-Dev] PEPs: ``.. code:: python`` or ``::`` (syntax highlighting)
- Next message (by thread): [Python-Dev] Py_DECREF(m) on PyInit_xxx() failure?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]