@@ -1482,6 +1482,63 @@ test_type_from_ephemeral_spec(PyObject *self, PyObject *Py_UNUSED(ignored))
1482
1482
return result ;
1483
1483
}
1484
1484
1485
+ PyType_Slot repeated_doc_slots [] = {
1486
+ {Py_tp_doc , "A class used for tests·" },
1487
+ {Py_tp_doc , "A class used for tests" },
1488
+ {0 , 0 },
1489
+ };
1490
+
1491
+ PyType_Spec repeated_doc_slots_spec = {
1492
+ .name = "RepeatedDocSlotClass" ,
1493
+ .basicsize = sizeof (PyObject ),
1494
+ .slots = repeated_doc_slots ,
1495
+ };
1496
+
1497
+ typedef struct {
1498
+ PyObject_HEAD
1499
+ int data ;
1500
+ } HeapCTypeWithDataObject ;
1501
+
1502
+
1503
+ static struct PyMemberDef members_to_repeat [] = {
1504
+ {"T_INT" , T_INT , offsetof(HeapCTypeWithDataObject , data ), 0 , NULL },
1505
+ {NULL }
1506
+ };
1507
+
1508
+ PyType_Slot repeated_members_slots [] = {
1509
+ {Py_tp_members , members_to_repeat },
1510
+ {Py_tp_members , members_to_repeat },
1511
+ {0 , 0 },
1512
+ };
1513
+
1514
+ PyType_Spec repeated_members_slots_spec = {
1515
+ .name = "RepeatedMembersSlotClass" ,
1516
+ .basicsize = sizeof (HeapCTypeWithDataObject ),
1517
+ .slots = repeated_members_slots ,
1518
+ };
1519
+
1520
+ static PyObject *
1521
+ create_type_from_repeated_slots (PyObject * self , PyObject * variant_obj )
1522
+ {
1523
+ PyObject * class = NULL ;
1524
+ int variant = PyLong_AsLong (variant_obj );
1525
+ if (PyErr_Occurred ()) {
1526
+ return NULL ;
1527
+ }
1528
+ switch (variant ) {
1529
+ case 0 :
1530
+ class = PyType_FromSpec (& repeated_doc_slots_spec );
1531
+ break ;
1532
+ case 1 :
1533
+ class = PyType_FromSpec (& repeated_members_slots_spec );
1534
+ break ;
1535
+ default :
1536
+ PyErr_SetString (PyExc_ValueError , "bad test variant" );
1537
+ break ;
1538
+ }
1539
+ return class ;
1540
+ }
1541
+
1485
1542
1486
1543
static PyObject *
1487
1544
test_get_type_qualname (PyObject * self , PyObject * Py_UNUSED (ignored ))
@@ -6107,6 +6164,8 @@ static PyMethodDef TestMethods[] = {
6107
6164
{"test_get_type_name" , test_get_type_name , METH_NOARGS },
6108
6165
{"test_get_type_qualname" , test_get_type_qualname , METH_NOARGS },
6109
6166
{"test_type_from_ephemeral_spec" , test_type_from_ephemeral_spec , METH_NOARGS },
6167
+ {"create_type_from_repeated_slots" ,
6168
+ create_type_from_repeated_slots , METH_O },
6110
6169
{"test_from_spec_metatype_inheritance" , test_from_spec_metatype_inheritance ,
6111
6170
METH_NOARGS },
6112
6171
{"test_from_spec_invalid_metatype_inheritance" ,
0 commit comments