Py_INCREF() incomprehension
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sun May 1 18:48:58 EDT 2011
Hegedüs Ervin wrote:
> I've put it a Py_INCREF() after every PyModule_AddObject(), eg.:
>
> PyModule_AddObject(o, "error", cibcrypt_error_nokey);
> Py_INCREF(cibcrypt_error_nokey);
That looks correct, because PyModule_AddObject is documented as
stealing a reference to the object.
By the way, it probably doesn't make a difference here, but
it's better style to do the Py_INCREF *before* calling
a function that steals a reference, to be sure that the
object can't get spuriously deallocated.
--
Greg
More information about the Python-list
mailing list