[Pyrex] Special methods do not type cast 'self'

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Tue Jul 18 15:41:11 UTC 2006


Hi,

I just stumbled over this:

    cdef class _NumberElement(BaseClass):
        cdef _value(self):
            return 1
        def __add__(self, other):
            return self._value() + other

This does not work. It generates this code in the __add__ function:

[...]
__pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n__value); if [...]

which obviously fails to find the C method. I can work around this with a type
cast, but I think this should be fixed.

Stefan



More information about the Pyrex mailing list