@@ -6215,6 +6215,47 @@ static PyTypeObject MethodDescriptor2_Type = {
62156215 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL ,
62166216};
62176217
6218+ PyDoc_STRVAR (heapdocctype__doc__ ,
6219+ "HeapDocCType(arg1, arg2)\n"
6220+ "--\n"
6221+ "\n"
6222+ "somedoc" );
6223+
6224+ typedef struct {
6225+ PyObject_HEAD
6226+ } HeapDocCTypeObject ;
6227+
6228+ static PyType_Slot HeapDocCType_slots [] = {
6229+ {Py_tp_doc , (char * )heapdocctype__doc__ },
6230+ {0 },
6231+ };
6232+
6233+ static PyType_Spec HeapDocCType_spec = {
6234+ "_testcapi.HeapDocCType" ,
6235+ sizeof (HeapDocCTypeObject ),
6236+ 0 ,
6237+ Py_TPFLAGS_DEFAULT ,
6238+ HeapDocCType_slots
6239+ };
6240+
6241+ typedef struct {
6242+ PyObject_HEAD
6243+ } NullTpDocTypeObject ;
6244+
6245+ static PyType_Slot NullTpDocType_slots [] = {
6246+ {Py_tp_doc , NULL },
6247+ {0 , 0 },
6248+ };
6249+
6250+ static PyType_Spec NullTpDocType_spec = {
6251+ "_testcapi.NullTpDocType" ,
6252+ sizeof (NullTpDocTypeObject ),
6253+ 0 ,
6254+ Py_TPFLAGS_DEFAULT ,
6255+ NullTpDocType_slots
6256+ };
6257+
6258+
62186259PyDoc_STRVAR (heapgctype__doc__ ,
62196260"A heap type with GC, and with overridden dealloc.\n\n"
62206261"The 'value' attribute is set to 10 in __init__." );
@@ -6883,6 +6924,20 @@ PyInit__testcapi(void)
68836924 Py_INCREF (TestError );
68846925 PyModule_AddObject (m , "error" , TestError );
68856926
6927+ PyObject * HeapDocCType = PyType_FromSpec (& HeapDocCType_spec );
6928+ if (HeapDocCType == NULL ) {
6929+ return NULL ;
6930+ }
6931+ PyModule_AddObject (m , "HeapDocCType" , HeapDocCType );
6932+
6933+ /* bpo-41832: Add a new type to test PyType_FromSpec()
6934+ now can accept a NULL tp_doc slot. */
6935+ PyObject * NullTpDocType = PyType_FromSpec (& NullTpDocType_spec );
6936+ if (NullTpDocType == NULL ) {
6937+ return NULL ;
6938+ }
6939+ PyModule_AddObject (m , "NullTpDocType" , NullTpDocType );
6940+
68866941 PyObject * HeapGcCType = PyType_FromSpec (& HeapGcCType_spec );
68876942 if (HeapGcCType == NULL ) {
68886943 return NULL ;
0 commit comments