[pypy-commit] pypy release-pypy2.7-5.x: add failing test for multiple bases
mattip
pypy.commits at gmail.com
Mon Mar 27 12:38:27 EDT 2017
Author: Matti Picus <matti.picus at gmail.com>
Branch: release-pypy2.7-5.x
Changeset: r90825:99bc8099921e
Date: 2017-03-27 19:17 +0300
http://bitbucket.org/pypy/pypy/changeset/99bc8099921e/
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
@@ -974,6 +974,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:
More information about the pypy-commit
mailing list