Author: Matti Picus <matti.pi...@gmail.com> Branch: release-pypy3.5-5.x Changeset: r90923:22286c1b31a8 Date: 2017-04-02 20:38 +0300 http://bitbucket.org/pypy/pypy/changeset/22286c1b31a8/
Log: add failing test for multiple bases (grafted from 65ab47447a582ca2353f043d84d9d8225554d3bc) diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c --- a/pypy/module/cpyext/test/foo.c +++ b/pypy/module/cpyext/test/foo.c @@ -160,6 +160,28 @@ return PyObject_GenericSetAttr((PyObject *)self, name, value); } +static PyObject * +new_fooType(PyTypeObject * t, PyObject *args, PyObject *kwds) +{ + PyObject * o; + /* copied from numpy scalartypes.c for inherited classes */ + if (t->tp_bases && (PyTuple_GET_SIZE(t->tp_bases) > 1)) + { + PyTypeObject *sup; + /* We are inheriting from a Python type as well so + give it first dibs on conversion */ + sup = (PyTypeObject *)PyTuple_GET_ITEM(t->tp_bases, 1); + /* Prevent recursion */ + if (new_fooType != sup->tp_new) + { + o = sup->tp_new(t, args, kwds); + return o; + } + } + o = t->tp_alloc(t, 0); + return o; +}; + static PyMemberDef foo_members[] = { {"int_member", T_INT, offsetof(fooobject, foo), 0, "A helpful docstring."}, 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 @@ -949,6 +949,8 @@ pass class foo(f2, f1): pass + + x = foo(1) assert bar.__base__ is f2 # On cpython, the size changes. if '__pypy__' in sys.builtin_module_names: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit