[pypy-issue] Issue #2423: [cpyext] wrong __new__ assigned to tp_new for app-level classes (pypy/pypy)
issues-reply at bitbucket.org
Thu Oct 20 03:34:18 EDT 2016
New issue 2423: [cpyext] wrong __new__ assigned to tp_new for app-level classes
I created a test in the ``missing-tp_new`` branch that demonstrates how an app-level class's ``__new__`` is not assigned to the ``tp_new`` slot, rather the generic ``object``'s ``__new__`` is assigned instead. AFAICT the problem is in the use of ``typedef = w_type.layout.typedef`` in line 249 of cpyext.py. The typedef is not unique to the w_type, and this non-unique object is used as a part of the key to lookup wrappers in the slotdef.py ``SLOTS`` dictionary.
I think this is only a problem for the ``__new__`` method. I tried working around it by creating another ``NEW`` dictionary for the tp_new slot (as a special case in ``update_all_slots``, but could not get the pieces quite in the right place to make it translate.
More information about the pypy-issue