diff options
author | Hai Shi <shihai1992@gmail.com> | 2020-11-06 16:04:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 16:04:47 (GMT) |
commit | 88c2cfd9ffbcfc43fd1364f2984852a819547d43 (patch) | |
tree | 85571ab2d826b5eed1e084c9b973e3f9016fecd9 /Modules | |
parent | 803187796f06bdc47ae74ce3d28c443e8cc2a27f (diff) | |
download | cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.zip cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.gz cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.bz2 |
bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (GH-23123)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_lsprof.c | 4 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 78d464d..c32699c 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -489,15 +489,15 @@ static PyStructSequence_Field profiler_subentry_fields[] = { static PyStructSequence_Desc profiler_entry_desc = { .name = "_lsprof.profiler_entry", - .doc = "", .fields = profiler_entry_fields, + .doc = NULL, .n_in_sequence = 6 }; static PyStructSequence_Desc profiler_subentry_desc = { .name = "_lsprof.profiler_subentry", - .doc = "", .fields = profiler_subentry_fields, + .doc = NULL, .n_in_sequence = 5 }; diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 28d2c12..22d20d2 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; |