bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (GH-23123)

This commit is contained in:
Hai Shi 2020-11-07 00:04:47 +08:00 committed by GitHub
parent 803187796f
commit 88c2cfd9ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 4 deletions

View file

@ -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) {