[Pyrex] Inheritance for extension types

Jiba jiba at tuxfamily.org
Thu Feb 12 22:30:34 CET 2004


On Thu, 12 Feb 2004 15:07:22 +0100
Konrad Hinsen <hinsen at cnrs-orleans.fr> wrote:

> On Thursday 12 February 2004 13:34, q q wrote:
> 
> > This does not compile and i get a traceback from
> > Python.
> 
> Your example compiles fine for me, and I can import the resulting
> module. I can also create instances of type A. Creating an instance of
> type B causes a crash though.
> 
> I guess the reason is that you are calling a superclass method within
> __new__. When the method __new__ is called, the object is not yet in a
> consistent internal state, which means that some operations are not
> allowed. I don't know the details because I don't need to - unless you
> have a good reason to implement __new__, just implement (and override)
> __init__. In fact, it you replace __new__ by __init__ in your code,
> you should get everything working as expected.

or maybe it is because __new__ has a different meaning in Pyrex and in
Python (according to the Pyrex doc).
when you define __new__, you define it in Pyrex. When you call it, you
call the Python __new__ i believe, since there is no mean to call a
Pyrex method by doing class.my_method(self,...).

Jiba




More information about the Pyrex mailing list