Subclassing in C

Michael Hudson mwh at python.net
Wed Sep 15 08:03:37 EDT 2004


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

> Michael Hudson wrote:
> > Iker Arizmendi <iker at research.att.com> writes:
> > 
> >>(*) 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.
> 
> Ah! I missed the trailing 'o' and set tp_getattr, not
> tp_getattro as you suggested.

[snip]

OK, some questions.

1) You must be assuming 2.2 or later, right?  tp_base doesn't make
   sense before then.
2) Is this a third party base type?
3) If 2) is the third party assuming 2.2 or later?

If 2) but not 3), you might be in for some hacking (as you later came
up with).  You can't really subclass (cleanly) a type that's totally
unprepared for it.

Py_FindMethod() is SO 2001 :-)

Cheers,
mwh

-- 
  <Erwin> I recompiled XFree 4.2 with gcc 3.2-beta-from-cvs with -O42
          and -march-pentium4-800Mhz and I am sure that the MOUSE
          CURSOR is moving 5 % FASTER!
                                                -- from Twisted.Quotes



More information about the Python-list mailing list