Author: mattip <matti.pi...@gmail.com> Branch: cpyext-ext Changeset: r81595:d32637ebd6d9 Date: 2016-01-05 01:11 +0200 http://bitbucket.org/pypy/pypy/changeset/d32637ebd6d9/
Log: add protective hack to work around PyString_Type missing a ob_type reference, give up writing a test to properly fix it 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 @@ -514,7 +514,7 @@ pto.c_tp_basicsize = -1 # hopefully this makes malloc bail out pto.c_tp_itemsize = 0 # uninitialized fields: - # c_tp_print, c_tp_getattr, c_tp_setattr + # c_tp_print # XXX implement # c_tp_compare and the following fields (see http://docs.python.org/c-api/typeobj.html ) w_base = best_base(space, w_type.bases_w) @@ -605,9 +605,14 @@ finish_type_1(space, py_type) - w_metatype = from_ref(space, rffi.cast(PyObject, py_type.c_ob_type)) + if py_type.c_ob_type: + w_metatype = from_ref(space, rffi.cast(PyObject, py_type.c_ob_type)) + else: + # Somehow the tp_base type is created with no ob_type, notably + # PyString_Type and PyBaseString_Type + # While this is a hack, cpython does it as well. + w_metatype = space.w_type - assert w_metatype # XXX in numpy initmultiarray, py_type.c_ob_type is 0 w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype) track_reference(space, py_obj, w_obj) w_obj.__init__(space, py_type) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit