@@ -3990,21 +3990,6 @@ test_structseq_newtype_doesnt_leak(PyObject *Py_UNUSED(self),
3990
3990
Py_RETURN_NONE ;
3991
3991
}
3992
3992
3993
- static PyType_Spec HeapDocCType_spec ;
3994
-
3995
- static PyObject *
3996
- test_PyType_FromSpec (PyObject * Py_UNUSED (self ), PyObject * Py_UNUSED (args ))
3997
- {
3998
- void * tp_doc = HeapDocCType_spec .slots [0 ].pfunc ;
3999
- HeapDocCType_spec .slots [0 ].pfunc = NULL ;
4000
- PyObject * HeapDocCType = PyType_FromSpec (& HeapDocCType_spec );
4001
- assert (HeapDocCType != NULL );
4002
- HeapDocCType_spec .slots [0 ].pfunc = tp_doc ;
4003
- Py_DECREF (HeapDocCType );
4004
-
4005
- Py_RETURN_NONE ;
4006
- }
4007
-
4008
3993
static PyObject *
4009
3994
test_incref_decref_API (PyObject * ob , PyObject * Py_UNUSED (ignored ))
4010
3995
{
@@ -5616,7 +5601,6 @@ static PyMethodDef TestMethods[] = {
5616
5601
{"test_decref_doesnt_leak" , test_decref_doesnt_leak , METH_NOARGS },
5617
5602
{"test_structseq_newtype_doesnt_leak" ,
5618
5603
test_structseq_newtype_doesnt_leak , METH_NOARGS },
5619
- {"test_PyType_FromSpec" , test_PyType_FromSpec , METH_NOARGS },
5620
5604
{"test_incref_decref_API" , test_incref_decref_API , METH_NOARGS },
5621
5605
{"test_long_and_overflow" , test_long_and_overflow , METH_NOARGS },
5622
5606
{"test_long_as_double" , test_long_as_double , METH_NOARGS },
@@ -6524,6 +6508,23 @@ static PyType_Spec HeapDocCType_spec = {
6524
6508
HeapDocCType_slots
6525
6509
};
6526
6510
6511
+ typedef struct {
6512
+ PyObject_HEAD
6513
+ } NullTpDocTypeObject ;
6514
+
6515
+ static PyType_Slot NullTpDocType_slots [] = {
6516
+ {Py_tp_doc , NULL },
6517
+ {0 , 0 },
6518
+ };
6519
+
6520
+ static PyType_Spec NullTpDocType_spec = {
6521
+ "_testcapi.NullTpDocType" ,
6522
+ sizeof (NullTpDocTypeObject ),
6523
+ 0 ,
6524
+ Py_TPFLAGS_DEFAULT ,
6525
+ NullTpDocType_slots
6526
+ };
6527
+
6527
6528
6528
6529
PyDoc_STRVAR (heapgctype__doc__ ,
6529
6530
"A heap type with GC, and with overridden dealloc.\n\n"
@@ -7199,6 +7200,12 @@ PyInit__testcapi(void)
7199
7200
}
7200
7201
PyModule_AddObject (m , "HeapDocCType" , HeapDocCType );
7201
7202
7203
+ PyObject * NullTpDocType = PyType_FromSpec (& NullTpDocType_spec );
7204
+ if (NullTpDocType == NULL ) {
7205
+ return NULL ;
7206
+ }
7207
+ PyModule_AddObject (m , "NullTpDocType" , NullTpDocType );
7208
+
7202
7209
PyObject * HeapGcCType = PyType_FromSpec (& HeapGcCType_spec );
7203
7210
if (HeapGcCType == NULL ) {
7204
7211
return NULL ;
0 commit comments