Help with Extension Class Crash

G

Giles Brown

Hello folks,
I'm tryin to write an extension class in C (been a while since
I wrote some C :). I want the class to be inheritable from Python.
I've put the magic incantations into the type descriptor. But it
crashes. I've tracked the crash down to a call to PyObject_GenericGetAttr.

When I sub-class my class the tp_dictoffset comes out as -4 which

quoting from PyObject_GenericGetAttr:
"""
if (dictoffset < 0) {
int tsize;
size_t size;

tsize = ((PyVarObject *)obj)->ob_size;
if (tsize < 0)
tsize = -tsize;
size = _PyObject_VAR_SIZE(tp, tsize);

dictoffset += (long)size;
assert(dictoffset > 0);
assert(dictoffset % SIZEOF_VOID_P == 0);
}
dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr; <---- crash happens here
"""

The class I'm trying to create is a variable size class. Everything
is ok unless I sub-class it. I'm guess that maybe I haven't set the
sizes up ok so its sending the dictptr off into the blue. Or I've
missed setting of something, but not sure where to look.

Can anyone help?

Thanks,
Giles
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top