Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.6 Changeset: r98001:9661af74538e Date: 2019-11-09 02:52 +0000 http://bitbucket.org/pypy/pypy/changeset/9661af74538e/
Log: hg merge default diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -427,6 +427,30 @@ assert module.hack_tp_dict(obj, "b") == 2 + def test_tp_dict_ready(self): + module = self.import_extension('foo', [ + ("new_obj", "METH_NOARGS", + ''' + PyObject *obj; + obj = PyObject_New(PyObject, &Foo_Type); + return obj; + ''' + )], prologue=''' + static PyTypeObject Foo_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "foo.foo", + }; + ''', more_init = ''' + Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; + Foo_Type.tp_dict = PyDict_New(); + PyDict_SetItemString(Foo_Type.tp_dict, "inserted", Py_True); + if (PyType_Ready(&Foo_Type) < 0) INITERROR; + ''') + + obj = module.new_obj() + assert type(obj).inserted is True + + def test_tp_descr_get(self): module = self.import_extension('foo', [ ("tp_descr_get", "METH_O", 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 @@ -540,6 +540,13 @@ convert_getset_defs(space, dict_w, pto.c_tp_getset, self) convert_member_defs(space, dict_w, pto.c_tp_members, self) + w_dict = from_ref(space, pto.c_tp_dict) + if w_dict is not None: + dictkeys_w = space.listview(w_dict) + for w_key in dictkeys_w: + key = space.text_w(w_key) + dict_w[key] = space.getitem(w_dict, w_key) + flag_heaptype = pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE if flag_heaptype: minsize = rffi.sizeof(PyHeapTypeObject.TO) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit