Author: Armin Rigo <[email protected]>
Branch: cpyext-ext
Changeset: r82435:208a42ce0440
Date: 2016-02-23 13:59 +0100
http://bitbucket.org/pypy/pypy/changeset/208a42ce0440/
Log: fix
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
@@ -539,7 +539,13 @@
PyObject_Free.api_func.get_wrapper(space))
pto.c_tp_alloc = llhelper(PyType_GenericAlloc.api_func.functype,
PyType_GenericAlloc.api_func.get_wrapper(space))
- if pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE:
+ builder = space.fromcache(StaticObjectBuilder)
+ if ((pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE) != 0
+ and builder.cpyext_type_init is None):
+ # this ^^^ is not None only during startup of cpyext. At that
+ # point we might get into troubles by doing make_ref() when
+ # things are not initialized yet. So in this case, simply use
+ # str2charp() and "leak" the string.
w_typename = space.getattr(w_type, space.wrap('__name__'))
heaptype = rffi.cast(PyHeapTypeObject, pto)
heaptype.c_ht_name = make_ref(space, w_typename)
@@ -554,7 +560,6 @@
w_base = best_base(space, w_type.bases_w)
pto.c_tp_base = rffi.cast(PyTypeObjectPtr, make_ref(space, w_base))
- builder = space.fromcache(StaticObjectBuilder)
if builder.cpyext_type_init is not None:
builder.cpyext_type_init.append((pto, w_type))
else:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit