summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-11-06 16:04:47 (GMT)
committerGitHub <noreply@github.com>2020-11-06 16:04:47 (GMT)
commit88c2cfd9ffbcfc43fd1364f2984852a819547d43 (patch)
tree85571ab2d826b5eed1e084c9b973e3f9016fecd9 /Objects
parent803187796f06bdc47ae74ce3d28c443e8cc2a27f (diff)
downloadcpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.zip
cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.gz
cpython-88c2cfd9ffbcfc43fd1364f2984852a819547d43.tar.bz2
bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (GH-23123)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 2daf374..3822b8c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3012,6 +3012,10 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
else if (slot->slot == Py_tp_doc) {
/* For the docstring slot, which usually points to a static string
literal, we need to make a copy */
+ if (slot->pfunc == NULL) {
+ type->tp_doc = NULL;
+ continue;
+ }
size_t len = strlen(slot->pfunc)+1;
char *tp_doc = PyObject_MALLOC(len);
if (tp_doc == NULL) {