Subclassing in C

Michael Hudson mwh at python.net
Tue Sep 14 12:17:23 EDT 2004


Iker Arizmendi <iker at research.att.com> writes:

> I was setting tp_getattr to 0 in my subclass (*), but when
> I set it to PyObject_GenericGetAttr Python crashed. What
> does PyObject_GenericGetAttr do that would help in
> this case?

Well, it does "the usual" attribute access stuff.  Descriptors & so
on.  It's what object.__getattribute__ wraps.

> Regards,
> Iker
> 
> (*) The class I'm deriving from is defined in another
> extension module and it has its own tp_getattr method.

Hmm.  I take it *it's* tp_getattr[o] method isn't
PyObject_GenericGetAttr then?

Then your initial post makes more sense; I'm afraid I don't see
any obvious reason for PyObject_GenericGetAttr to crash.

> Here's the stack trace (via Valgrind), just in case:

A stack trace from gdb (i.e. with line numbers) would have been more
use.

I think you have two options here: (a) make friends with gdb or (b)
post [a link to, maybe] complete code.

Cheers,
mwh

-- 
  Those who have deviant punctuation desires should take care of their
  own perverted needs.                  -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list