@@ -3987,10 +3987,20 @@ test_structseq_newtype_doesnt_leak(PyObject *Py_UNUSED(self),
3987
3987
assert (PyType_FastSubclass (structseq_type , Py_TPFLAGS_TUPLE_SUBCLASS ));
3988
3988
Py_DECREF (structseq_type );
3989
3989
3990
- descr .doc = NULL ;
3991
- structseq_type = PyStructSequence_NewType (& descr );
3992
- assert (structseq_type != NULL );
3993
- Py_DECREF (structseq_type );
3990
+ Py_RETURN_NONE ;
3991
+ }
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 );
3994
4004
3995
4005
Py_RETURN_NONE ;
3996
4006
}
@@ -5606,6 +5616,7 @@ static PyMethodDef TestMethods[] = {
5606
5616
{"test_decref_doesnt_leak" , test_decref_doesnt_leak , METH_NOARGS },
5607
5617
{"test_structseq_newtype_doesnt_leak" ,
5608
5618
test_structseq_newtype_doesnt_leak , METH_NOARGS },
5619
+ {"test_PyType_FromSpec" , test_PyType_FromSpec , METH_NOARGS },
5609
5620
{"test_incref_decref_API" , test_incref_decref_API , METH_NOARGS },
5610
5621
{"test_long_and_overflow" , test_long_and_overflow , METH_NOARGS },
5611
5622
{"test_long_as_double" , test_long_as_double , METH_NOARGS },
0 commit comments