[pypy-issue] [issue825] StackOverflow when importing zope.interface

Amaury Forgeot d Arc tracker at bugs.pypy.org
Thu Aug 11 22:12:59 CEST 2011


Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:

It's actually a bug in the cpyext layer:

- All the types defined by the pypy interpreter share the same tp_new pointer. The code of this C 
function evaluates the Python expression cls.__new__(*args, **kw).

- When an extension type fills the tp_new slot, cpyext add to the type's dictionary a __new__ function 
that calls this tp_new.

- Now, zope.interface sets MyType.tp_new=PyBaseObject_Type.tp_new.  So the Python expression MyType() 
calls MyType.tp_new which evaluates MyType.__new__()... and you crash with a StackOverflow.

The fix would be to have different tp_new functions for each type defined in the pypy interpreter 
(=one C function for every Typedef.__new__), so that for example PyDict_Type.tp_new would call 
dict.__new__() instead of cls.__new__().
This has been implemented for tp_setattro, and should be extended to all slots.  I fear the code 
bloat, though.

----------
nosy: +afa

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue825>
________________________________________


More information about the pypy-issue mailing list