Author: Armin Rigo <ar...@tunes.org> Branch: cpyext-gc-support-2 Changeset: r81966:dfc37d8a80f8 Date: 2016-01-27 01:17 +0100 http://bitbucket.org/pypy/pypy/changeset/dfc37d8a80f8/
Log: More tweaks for bootstrapping diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py --- a/pypy/module/cpyext/pyobject.py +++ b/pypy/module/cpyext/pyobject.py @@ -5,7 +5,7 @@ from rpython.rtyper.extregistry import ExtRegistryEntry from pypy.module.cpyext.api import ( cpython_api, bootstrap_function, PyObject, PyObjectP, ADDR, - CANNOT_FAIL, Py_TPFLAGS_HEAPTYPE, PyTypeObjectPtr, + CANNOT_FAIL, Py_TPFLAGS_HEAPTYPE, PyTypeObjectPtr, is_PyObject, INTERPLEVEL_API) from pypy.module.cpyext.state import State from pypy.objspace.std.typeobject import W_TypeObject @@ -212,7 +212,7 @@ assert is_pyobj(ref) if not ref: return None - w_obj = rawrefcount.to_obj(W_Root, pyobj) + w_obj = rawrefcount.to_obj(W_Root, ref) if w_obj is not None: return w_obj 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 @@ -324,9 +324,21 @@ track_reference(space, py_type, space.w_type) type_attach(space, py_type, space.w_type) + as_pyobj(space, space.w_str) + as_pyobj(space, space.w_tuple) + as_pyobj(space, space.w_object) + + delayed_types = [] while space._cpyext_delay_type_creation: - _type_really_attach(space, *space._cpyext_delay_type_creation.pop()) + (py_obj, w_type) = space._cpyext_delay_type_creation.pop() + _type_really_attach(space, py_obj, w_type) + delayed_types.append((py_obj, w_type)) del space._cpyext_delay_type_creation + for py_obj, w_type in delayed_types: + pto = rffi.cast(PyTypeObjectPtr, py_obj) + finish_type_1(space, pto) + finish_type_2(space, pto, w_type) + finish_type_3(space, pto, w_type) @cpython_api([PyObject], lltype.Void, external=False) @@ -493,8 +505,9 @@ py_base = make_ref(space, w_base) pto.c_tp_base = rffi.cast(PyTypeObjectPtr, py_base) - finish_type_1(space, pto) - finish_type_2(space, pto, w_type) + if not hasattr(space, '_cpyext_delay_type_creation'): + finish_type_1(space, pto) + finish_type_2(space, pto, w_type) pto.c_tp_basicsize = rffi.sizeof(typedescr.basestruct) if pto.c_tp_base: @@ -507,6 +520,12 @@ pto.c_tp_new = rffi.cast(newfunc, 1) update_all_slots(space, w_type, pto) + if not hasattr(space, '_cpyext_delay_type_creation'): + finish_type_3(space, pto, w_type) + + pto.c_tp_flags |= Py_TPFLAGS_READY + +def finish_type_3(space, pto, w_type): if pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE: w_typename = space.getattr(w_type, space.wrap('__name__')) heaptype = rffi.cast(PyHeapTypeObject, pto) @@ -516,8 +535,6 @@ else: pto.c_tp_name = rffi.str2charp(w_type.name) - pto.c_tp_flags |= Py_TPFLAGS_READY - def py_type_ready(space, pto): if pto.c_tp_flags & Py_TPFLAGS_READY: return @@ -608,8 +625,7 @@ base = pto.c_tp_base base_pyo = rffi.cast(PyObject, pto.c_tp_base) if base and not base.c_tp_flags & Py_TPFLAGS_READY: - if not hasattr(space, '_cpyext_delay_type_creation'): - type_realize(space, rffi.cast(PyObject, base_pyo)) + type_realize(space, rffi.cast(PyObject, base_pyo)) if base and not pto.c_ob_type: # will be filled later pto.c_ob_type = base.c_ob_type if not pto.c_tp_bases: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit