Skip to content

Commit 95c30a0

Browse files
committed
Add temporary debug helper for PyPy
1 parent a567979 commit 95c30a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_multiple_inheritance.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ test_initializer multiple_inheritance([](py::module &m) {
4343

4444
py::class_<MIType, Base12>(m, "MIType")
4545
.def(py::init<int, int>());
46+
47+
// FIXME: Temporary to debug PyPy behaviour
48+
m.def("debug_tp_bases", [](py::object pbo) {
49+
PyObject *o = pbo.ptr();
50+
if (PyType_Check(o)) {
51+
PyTypeObject *t = (PyTypeObject *) o;
52+
py::print("Type `{}' tp_bases:"_s.format(t->tp_name));
53+
if (!PyTuple_Check(t->tp_bases)) {
54+
py::print(" (null tp_bases)");
55+
}
56+
else {
57+
for (int i = 0; i < PyTuple_GET_SIZE(t->tp_bases); i++) {
58+
PyObject *subtype = PyTuple_GET_ITEM(t->tp_bases, i);
59+
if (PyType_Check(subtype))
60+
py::print(" - {}"_s.format(((PyTypeObject *) subtype)->tp_name));
61+
else
62+
py::print(" - (unknown - not a type?)");
63+
}
64+
}
65+
}
66+
});
4667
});
4768

4869
/* Test the case where not all base classes are specified,

0 commit comments

Comments
 (0)