Hi all,
I'm currently building an extension module by hand and am confused by
the fact that as well xxmodule.c as structmodule.c and other examples
increment the refcount of the exception type(s) they are defining.
I. e. from xxmodule.c:
if (ErrorObject == NULL) {
ErrorObject = PyErr_NewExcept ion("xx.error", NULL, NULL);
if (ErrorObject == NULL)
return;
}
Py_INCREF(Error Object);
^^^^^^^^^^^^^^^ ^^^^^^^^ I mean this one.
PyModule_AddObj ect(m, "error", ErrorObject);
I know that PyModule_AddObj ect steals a reference, but now
ErrorObject's refcount should be 2, isn't it? I just fail to see
how the refcount can return to 0. I'm sure this is simple to explain,
so please enlighten me, why this isn't a leak.
cheers,
aa
I'm currently building an extension module by hand and am confused by
the fact that as well xxmodule.c as structmodule.c and other examples
increment the refcount of the exception type(s) they are defining.
I. e. from xxmodule.c:
if (ErrorObject == NULL) {
ErrorObject = PyErr_NewExcept ion("xx.error", NULL, NULL);
if (ErrorObject == NULL)
return;
}
Py_INCREF(Error Object);
^^^^^^^^^^^^^^^ ^^^^^^^^ I mean this one.
PyModule_AddObj ect(m, "error", ErrorObject);
I know that PyModule_AddObj ect steals a reference, but now
ErrorObject's refcount should be 2, isn't it? I just fail to see
how the refcount can return to 0. I'm sure this is simple to explain,
so please enlighten me, why this isn't a leak.
cheers,
aa
Comment