@@ -410,6 +410,26 @@ pyobject_getitemdata(PyObject *self, PyObject *o)
410410}
411411
412412
413+ static PyType_Slot HeapCTypeWithBasesSlotNone_slots [] = {
414+ {Py_tp_bases , NULL }, /* filled out with Py_None in runtime */
415+ {0 , 0 },
416+ };
417+
418+ static PyType_Spec HeapCTypeWithBasesSlotNone_spec = {
419+ .name = "_testcapi.HeapCTypeWithBasesSlotNone" ,
420+ .basicsize = sizeof (PyObject ),
421+ .flags = Py_TPFLAGS_DEFAULT ,
422+ .slots = HeapCTypeWithBasesSlotNone_slots
423+ };
424+
425+ static PyObject *
426+ create_heapctype_with_none_bases_slot (PyObject * self , PyObject * Py_UNUSED (ignored ))
427+ {
428+ HeapCTypeWithBasesSlotNone_slots [0 ].pfunc = Py_None ;
429+ return PyType_FromSpec (& HeapCTypeWithBasesSlotNone_spec );
430+ }
431+
432+
413433static PyMethodDef TestMethods [] = {
414434 {"pytype_fromspec_meta" , pytype_fromspec_meta , METH_O },
415435 {"test_type_from_ephemeral_spec" , test_type_from_ephemeral_spec , METH_NOARGS },
@@ -423,6 +443,8 @@ static PyMethodDef TestMethods[] = {
423443 {"make_immutable_type_with_base" , make_immutable_type_with_base , METH_O },
424444 {"make_type_with_base" , make_type_with_base , METH_O },
425445 {"pyobject_getitemdata" , pyobject_getitemdata , METH_O },
446+ {"create_heapctype_with_none_bases_slot" ,
447+ create_heapctype_with_none_bases_slot , METH_NOARGS },
426448 {NULL },
427449};
428450
@@ -751,6 +773,18 @@ static PyType_Spec HeapCTypeMetaclassNullNew_spec = {
751773 .slots = empty_type_slots
752774};
753775
776+ static PyType_Slot HeapCTypeWithBasesSlot_slots [] = {
777+ {Py_tp_bases , NULL }, /* filled out in module init function */
778+ {0 , 0 },
779+ };
780+
781+ static PyType_Spec HeapCTypeWithBasesSlot_spec = {
782+ .name = "_testcapi.HeapCTypeWithBasesSlot" ,
783+ .basicsize = sizeof (PyLongObject ),
784+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE ,
785+ .slots = HeapCTypeWithBasesSlot_slots
786+ };
787+
754788
755789typedef struct {
756790 PyObject_HEAD
@@ -1201,6 +1235,18 @@ _PyTestCapi_Init_Heaptype(PyObject *m) {
12011235 & PyType_Type , m , & HeapCTypeMetaclassNullNew_spec , (PyObject * ) & PyType_Type );
12021236 ADD ("HeapCTypeMetaclassNullNew" , HeapCTypeMetaclassNullNew );
12031237
1238+ PyObject * bases = PyTuple_Pack (1 , & PyLong_Type );
1239+ if (bases == NULL ) {
1240+ return -1 ;
1241+ }
1242+ HeapCTypeWithBasesSlot_slots [0 ].pfunc = bases ;
1243+ PyObject * HeapCTypeWithBasesSlot = PyType_FromSpec (& HeapCTypeWithBasesSlot_spec );
1244+ Py_DECREF (bases );
1245+ if (HeapCTypeWithBasesSlot == NULL ) {
1246+ return -1 ;
1247+ }
1248+ ADD ("HeapCTypeWithBasesSlot" , HeapCTypeWithBasesSlot );
1249+
12041250 PyObject * HeapCCollection = PyType_FromMetaclass (
12051251 NULL , m , & HeapCCollection_spec , NULL );
12061252 if (HeapCCollection == NULL ) {
0 commit comments