@@ -507,24 +507,11 @@ int PyType_Ready(PyTypeObject* cls) {
507507 PyObject * mro = GraalPyTruffle_Compute_Mro (cls , truffleString (cls -> tp_name ));
508508 set_PyTypeObject_tp_mro (cls , mro );
509509
510- /* Inherit special flags from dominant base */
511- if (base != NULL )
512- inherit_special (cls , base );
513-
514- /* Initialize tp_dict properly */
515- bases = mro ;
516- assert (bases != NULL );
517- assert (PyTuple_Check (bases ));
518- n = PyTuple_GET_SIZE (bases );
519- for (i = 1 ; i < n ; i ++ ) {
520- PyObject * b = PyTuple_GET_ITEM (bases , i );
521- if (PyType_Check (b ))
522- inherit_slots (cls , (PyTypeObject * )b );
523- }
524-
510+ /* set new and alloc */
525511 ADD_IF_MISSING (cls -> tp_alloc , PyType_GenericAlloc );
526512 ADD_IF_MISSING (cls -> tp_new , PyType_GenericNew );
527513
514+ /* fill dict */
528515 // add special methods defined directly on the type structs
529516 ADD_SLOT_CONV ("__dealloc__" , cls -> tp_dealloc , -1 , JWRAPPER_DIRECT );
530517 // https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_getattr
@@ -655,6 +642,19 @@ int PyType_Ready(PyTypeObject* cls) {
655642 // TODO ...
656643 }
657644
645+ /* Inherit slots */
646+ if (base != NULL )
647+ inherit_special (cls , base );
648+ bases = mro ;
649+ assert (bases != NULL );
650+ assert (PyTuple_Check (bases ));
651+ n = PyTuple_GET_SIZE (bases );
652+ for (i = 1 ; i < n ; i ++ ) {
653+ PyObject * b = PyTuple_GET_ITEM (bases , i );
654+ if (PyType_Check (b ))
655+ inherit_slots (cls , (PyTypeObject * )b );
656+ }
657+
658658 // process inherited slots
659659 // CPython doesn't do that in 'PyType_Ready' but we must because a native type can inherit
660660 // dynamic slots from a managed Python class. Since the managed Python class may be created
0 commit comments