[pypy-commit] pypy default: issue 3117: calling PyType_Ready on a subclass with a partially built tp_base
mattip
pypy.commits at gmail.com
Mon Nov 18 06:37:36 EST 2019
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r98109:7fd34a4a2b89
Date: 2019-11-18 04:33 -0700
http://bitbucket.org/pypy/pypy/changeset/7fd34a4a2b89/
Log: issue 3117: calling PyType_Ready on a subclass with a partially
built tp_base
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -912,8 +912,10 @@
# While this is a hack, cpython does it as well.
w_metatype = space.w_type
- w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype)
- track_reference(space, py_obj, w_obj)
+ w_obj = rawrefcount.to_obj(W_PyCTypeObject, py_obj)
+ if w_obj is None:
+ w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype)
+ track_reference(space, py_obj, w_obj)
# __init__ wraps all slotdefs functions from py_type via add_operators
w_obj.__init__(space, py_type)
w_obj.ready()
@@ -940,7 +942,7 @@
Sets up tp_bases, necessary before creating the interpreter type.
"""
base = pto.c_tp_base
- base_pyo = rffi.cast(PyObject, pto.c_tp_base)
+ base_pyo = rffi.cast(PyObject, base)
if base and not base.c_tp_flags & Py_TPFLAGS_READY:
type_realize(space, base_pyo)
if base and not pto.c_ob_type: # will be filled later
More information about the pypy-commit
mailing list