Author: Armin Rigo <[email protected]>
Branch: cpyext-gc-support
Changeset: r80351:6d455e8db843
Date: 2015-10-20 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/6d455e8db843/
Log: progress
diff --git a/pypy/module/cpyext/methodobject.py
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -159,7 +159,7 @@
self.doc = doc
self.func = func
pyo = rffi.cast(PyObject, pto)
- w_type = from_ref(space, pyo)
+ w_type = from_pyobj(space, pyo)
assert isinstance(w_type, W_TypeObject)
self.w_objclass = w_type
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
@@ -235,7 +235,7 @@
return
pyo = rffi.cast(PyObject, pto)
dict_w["__new__"] = PyCFunction_NewEx(space, get_new_method_def(space),
- from_ref(space, pyo), None)
+ from_pyobj(space, pyo), None)
def inherit_special(space, pto, base_pto):
# XXX missing: copy basicsize and flags in a magical way
@@ -286,7 +286,8 @@
basestruct=PyTypeObject,
alloc_pyobj=type_alloc_pyobj,
fill_pyobj=type_fill_pyobj,
- alloc_pypy=type_alloc_pypy)
+ alloc_pypy=type_alloc_pypy,
+ fill_pypy=type_fill_pypy)
#dealloc=type_dealloc)
# some types are difficult to create because of cycles.
@@ -544,17 +545,10 @@
pto = rffi.cast(PyTypeObjectPtr, py_obj)
assert pto.c_tp_flags & Py_TPFLAGS_READY == 0
assert pto.c_tp_flags & Py_TPFLAGS_READYING == 0
+ assert pto.c_ob_type
+ # ^^^ shouldn't reach this place if these conditions fail
+
pto.c_tp_flags |= Py_TPFLAGS_READYING
- try:
- w_type = _type_realize(space, pto)
- finally:
- pto.c_tp_flags &= ~Py_TPFLAGS_READYING
- pto.c_tp_flags |= Py_TPFLAGS_READY
- return w_type, False
-
-def _type_realize(space, pto):
- assert pto.c_ob_type
- # ^^^ we can't reach this place if c_ob_type is still NULL
if not pto.c_tp_base:
base = get_pyobj_and_incref(space, space.w_object)
@@ -564,12 +558,16 @@
if not pto.c_tp_bases:
w_bases = space.newtuple([from_pyobj(space, pto.c_tp_base)])
pto.c_tp_bases = get_pyobj_and_incref(space, w_bases)
- else:
- w_bases = from_pyobj(space, pto.c_tp_bases)
w_metatype = from_pyobj(space, pto.c_ob_type)
w_type = space.allocate_instance(W_TypeObject, w_metatype)
+ return w_type, False
+def type_fill_pypy(space, w_type, py_obj):
+ pto = rffi.cast(PyTypeObjectPtr, py_obj)
+ assert pto.c_tp_flags & Py_TPFLAGS_READYING
+
+ w_bases = from_pyobj(space, pto.c_tp_bases)
bases_w = space.fixedview(w_bases) or [space.w_object]
name = rffi.charp2str(pto.c_tp_name)
dict_w = {}
@@ -593,7 +591,7 @@
W_TypeObject.__init__(w_type, space, name, bases_w, dict_w)
- if not space.is_true(space.issubtype(self, space.w_type)):
+ if not space.is_true(space.issubtype(w_type, space.w_type)): # ZZZ?
w_type.flag_cpytype = True
w_type.flag_heaptype = False
if pto.c_tp_doc:
@@ -601,6 +599,8 @@
finish_type_2(space, pto, w_type)
w_type.ready()
+ pto.c_tp_flags &= ~Py_TPFLAGS_READYING
+ pto.c_tp_flags |= Py_TPFLAGS_READY
return w_type
def solid_base(space, w_type):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit