@@ -3919,6 +3919,30 @@ test_structseq_newtype_null_descr_doc(PyObject *Py_UNUSED(self),
39193919 Py_RETURN_NONE ;
39203920}
39213921
3922+ static PyObject *
3923+ test_structseq_newtype_from_heap (PyObject * Py_UNUSED (self ),
3924+ PyObject * Py_UNUSED (args ))
3925+ {
3926+ PyStructSequence_Desc descr ;
3927+ PyStructSequence_Field descr_fields [2 ];
3928+
3929+ descr_fields [0 ] = (PyStructSequence_Field ){"foo" , "foo value" };
3930+ descr_fields [1 ] = (PyStructSequence_Field ){0 , NULL };
3931+
3932+ descr .name = "_testcapi.test_descr" ;
3933+ descr .fields = descr_fields ;
3934+ descr .doc = "This is used to test for creating a new type from heap" ;
3935+ descr .n_in_sequence = 1 ;
3936+
3937+ PyTypeObject * structseq_type =
3938+ (PyTypeObject * )PyStructSequence_FromModuleAndDesc (NULL , & descr , 0 );
3939+ assert (structseq_type != NULL );
3940+ assert (PyType_Check (structseq_type ));
3941+ Py_DECREF (structseq_type );
3942+
3943+ Py_RETURN_NONE ;
3944+ }
3945+
39223946static PyObject *
39233947test_incref_decref_API (PyObject * ob , PyObject * Py_UNUSED (ignored ))
39243948{
@@ -5691,6 +5715,8 @@ static PyMethodDef TestMethods[] = {
56915715 test_structseq_newtype_doesnt_leak , METH_NOARGS },
56925716 {"test_structseq_newtype_null_descr_doc" ,
56935717 test_structseq_newtype_null_descr_doc , METH_NOARGS },
5718+ {"test_structseq_newtype_from_heap" ,
5719+ test_structseq_newtype_from_heap , METH_NOARGS },
56945720 {"test_incref_decref_API" , test_incref_decref_API , METH_NOARGS },
56955721 {"test_long_and_overflow" , test_long_and_overflow , METH_NOARGS },
56965722 {"test_long_as_double" , test_long_as_double , METH_NOARGS },
0 commit comments