@@ -507,24 +507,11 @@ int PyType_Ready(PyTypeObject* cls) {
507
507
PyObject * mro = GraalPyTruffle_Compute_Mro (cls , truffleString (cls -> tp_name ));
508
508
set_PyTypeObject_tp_mro (cls , mro );
509
509
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 */
525
511
ADD_IF_MISSING (cls -> tp_alloc , PyType_GenericAlloc );
526
512
ADD_IF_MISSING (cls -> tp_new , PyType_GenericNew );
527
513
514
+ /* fill dict */
528
515
// add special methods defined directly on the type structs
529
516
ADD_SLOT_CONV ("__dealloc__" , cls -> tp_dealloc , -1 , JWRAPPER_DIRECT );
530
517
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_getattr
@@ -655,6 +642,19 @@ int PyType_Ready(PyTypeObject* cls) {
655
642
// TODO ...
656
643
}
657
644
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
+
658
658
// process inherited slots
659
659
// CPython doesn't do that in 'PyType_Ready' but we must because a native type can inherit
660
660
// dynamic slots from a managed Python class. Since the managed Python class may be created
0 commit comments