[pypy-dev] Findings in the Cython test suite

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Apr 4 09:27:15 CEST 2012


2012/4/4 Stefan Behnel <stefan_ml at behnel.de>:
>> Its tp_call slot is called, but this is defined to __Pyx_PyCFunction_Call
>> which is #defined to PyObject_Call, which itself invokes the tp_call slot...
>
> Interesting. Then that's the wrong thing to do in PyPy. I guess you just
> put it there in your original patch because PyPy doesn't expose
> PyCFunction_Call() and it seemed to be the obvious replacement.

I put it there to make the code compile... I did not even realize how
it was used.

>> A solution would be to access the "base" tp_call, the one that CPython
>> exposes as PyCFunction_Call.
>> Unfortunately cpyext only defines one tp_call shared by all types, one
>> which simply delegates to self.__call__.
>
> Makes sense for PyPy objects.

But not when those objects are subclassed:
self.__call__ always accesses the most derived method, whereas a tp_call slot
is supposed to point to the type being defined.

-- 
Amaury Forgeot d'Arc


More information about the pypy-dev mailing list