Skip to content

Commit c89eb93

Browse files
committed
Add test
1 parent 22c129c commit c89eb93

File tree

1 file changed

+25
-0
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+25
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_object.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,31 @@ def test_int(self):
109109
tester = TestInt()
110110
assert int(tester) == 42
111111

112+
def test_inherit_slots_with_managed_class(self):
113+
TestTpAllocWithManaged = CPyExtType("TestTpAllocWithManaged",
114+
"""
115+
static PyObject *test_alloc(PyTypeObject *type, Py_ssize_t nitems) {
116+
PyErr_SetString(PyExc_RuntimeError, "Should not call this tp_alloc");
117+
return NULL;
118+
}
119+
""",
120+
tp_alloc="test_alloc"
121+
)
122+
TestTpAllocCall = CPyExtType("TestTpAllocCall",
123+
'''
124+
static PyObject* testslots_tp_alloc(PyObject* self, PyObject *cls) {
125+
return ((PyTypeObject *)cls)->tp_alloc((PyTypeObject *) cls, 0);
126+
}
127+
''',
128+
tp_methods='{"createObj", (PyCFunction)testslots_tp_alloc, METH_O, ""}'
129+
)
130+
class managed(TestTpAllocWithManaged):
131+
pass
132+
t = TestTpAllocCall()
133+
134+
assert t.createObj(managed) != None
135+
136+
112137
def test_float_binops(self):
113138
TestFloatBinop = CPyExtType("TestFloatBinop",
114139
"""

0 commit comments

Comments
 (0)