aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-11-07 00:04:47 +0800
committerGitHub <noreply@github.com>2020-11-06 17:04:47 +0100
commit88c2cfd9ffbcfc43fd1364f2984852a819547d43 (patch)
tree85571ab2d826b5eed1e084c9b973e3f9016fecd9 /Modules/_testcapimodule.c
parentMinor grammar edits for the descriptor howto guide (GH-#23175) (diff)
downloadcpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.gz
cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.bz2
cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.zip
bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (GH-23123)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 28d2c124d51..22d20d220d4 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -6508,6 +6508,23 @@ static PyType_Spec HeapDocCType_spec = {
HeapDocCType_slots
};
+typedef struct {
+ PyObject_HEAD
+} NullTpDocTypeObject;
+
+static PyType_Slot NullTpDocType_slots[] = {
+ {Py_tp_doc, NULL},
+ {0, 0},
+};
+
+static PyType_Spec NullTpDocType_spec = {
+ "_testcapi.NullTpDocType",
+ sizeof(NullTpDocTypeObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ NullTpDocType_slots
+};
+
PyDoc_STRVAR(heapgctype__doc__,
"A heap type with GC, and with overridden dealloc.\n\n"
@@ -7183,6 +7200,14 @@ PyInit__testcapi(void)
}
PyModule_AddObject(m, "HeapDocCType", HeapDocCType);
+ /* bpo-41832: Add a new type to test PyType_FromSpec()
+ now can accept a NULL tp_doc slot. */
+ PyObject *NullTpDocType = PyType_FromSpec(&NullTpDocType_spec);
+ if (NullTpDocType == NULL) {
+ return NULL;
+ }
+ PyModule_AddObject(m, "NullTpDocType", NullTpDocType);
+
PyObject *HeapGcCType = PyType_FromSpec(&HeapGcCType_spec);
if (HeapGcCType == NULL) {
return NULL;