Skip to content

Commit d29cde5

Browse files
committed
Fix: avoid invalid call to explicit polyglot cast.
1 parent 5546009 commit d29cde5

File tree

1 file changed

+8
-2
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+8
-2
lines changed

graalpython/com.oracle.graal.python.cext/src/object.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,14 @@ int PyType_Ready(PyTypeObject* cls) {
460460
Py_ssize_t n = PyTuple_GET_SIZE(bases);
461461
Py_ssize_t i;
462462
for (i = 0; i < n; i++) {
463-
PyTypeObject *b = polyglot_as__typeobject(PyTuple_GetItem(bases, i));
464-
if (PyType_Check(b) && add_subclass((PyTypeObject *)b, cls) < 0) {
463+
PyObject* base_class_object = PyTuple_GetItem(bases, i);
464+
PyTypeObject* b = NULL;
465+
if (polyglot_is_value(base_class_object)) {
466+
b = polyglot_as__typeobject(base_class_object);
467+
} else {
468+
b = (PyTypeObject*) base_class_object;
469+
}
470+
if (PyType_Check(b) && add_subclass(b, cls) < 0) {
465471
cls->tp_flags &= ~Py_TPFLAGS_READYING;
466472
return -1;
467473
}

0 commit comments

Comments
 (0)