Skip to content

Commit 0ecc507

Browse files
committed
fix test case
1 parent 27cbd71 commit 0ecc507

File tree

1 file changed

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

1 file changed

+30
-8
lines changed

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

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,43 @@ def test_repr(self):
183183
def test_base_type(self):
184184
AcceptableBaseType = CPyExtType("AcceptableBaseType",
185185
'''
186+
static PyObject *
187+
TestBase_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
188+
{
189+
return PyType_Type.tp_new(type, args, kwds);
190+
}
186191
PyTypeObject TestBase_Type = {
187192
PyVarObject_HEAD_INIT(NULL, 0)
188-
.tp_name = "AcceptableBaseType",
193+
.tp_name = "TestBase",
189194
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
190195
};
196+
197+
static int
198+
AcceptableBaseType_traverse(AcceptableBaseTypeObject *self, visitproc visit, void *arg) {
199+
// This helps to avoid setting 'Py_TPFLAGS_HAVE_GC'
200+
// see typeobject.c:inherit_special:241
201+
return 0;
202+
}
203+
204+
static int
205+
AcceptableBaseType_clear(AcceptableBaseTypeObject *self) {
206+
// This helps to avoid setting 'Py_TPFLAGS_HAVE_GC'
207+
// see typeobject.c:inherit_special:241
208+
return 0;
209+
}
191210
''',
211+
tp_traverse="(traverseproc)AcceptableBaseType_traverse",
212+
tp_clear="(inquiry)AcceptableBaseType_clear",
192213
ready_code='''
193-
TestBase_Type.tp_base = &PyType_Type;
194-
if (PyType_Ready(&TestBase_Type) < 0)
195-
return NULL;
196-
Py_TYPE(&AcceptableBaseTypeType) = &TestBase_Type;
197-
AcceptableBaseTypeType.tp_base = &PyType_Type;
198-
''',
214+
TestBase_Type.tp_base = &PyType_Type;
215+
if (PyType_Ready(&TestBase_Type) < 0)
216+
return NULL;
217+
218+
Py_TYPE(&AcceptableBaseTypeType) = &TestBase_Type;
219+
AcceptableBaseTypeType.tp_base = &PyType_Type;''',
199220
)
200-
class AcceptableSubClass(AcceptableBaseType):
221+
class Foo(AcceptableBaseType):
222+
# This shouldn't fail
201223
pass
202224

203225
def test_new(self):

0 commit comments

Comments
 (0)