An unexpected visit_decref assertion fail (code works under python2.4, doesn't under 2.5)

J

Joe Ardent

Hello,

I'm running into a very odd problem here with a Python module (written
in C). The following code works fine when built against and loaded
into Python 2.4, but fails when built against and loaded into Python
2.5.1:

klass = PyClass_New(bases, classDict, className);
if (klass && methods) {
/* add methods to class */
for (def = methods; def->ml_name != NULL; def++) {
printf( "IlmPyClass: %d, def = %s\n", __LINE__, def-
ml_name );
PyObject *func = IlmPyClass_NewFunction(def);
if (!func) {
Py_XDECREF(klass);
return NULL;
}
printf( "We get here\n" );
func = PyMethod_New(func, NULL, klass);
printf( "We don't get here\n" );
# .......
}
}

The output of 'python2.5 -c "import mymod"' is:

"""
We get here
python2: Modules/gcmodule.c:276: visit_decref: Assertion `gc-
gc.gc_refs != 0' failed.
Abort
"""

The obvious things, such as Py_INCREFing klass or func, do not work.

What's extra strange, in addition to this code working fine in an
earlier python version, is that this code works fine for most of the
classes (this module has a bunch of C++ classes that get turned into
python classes).

Does anyone have any tips for debugging this? I'd really like to know
what exactly is being decref'd. This has been driving me crazy for a
while. Thanks in advance for any insights or tips!
 
A

Aahz

Does anyone have any tips for debugging this? I'd really like to know
what exactly is being decref'd. This has been driving me crazy for a
while. Thanks in advance for any insights or tips!

Try capi-sig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top