summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2021-05-04 16:07:13 +0200
committerGitHub <noreply@github.com>2021-05-04 16:07:13 +0200
commitec18362f6a7fdc02f9f982872fc1006bca31627d (patch)
tree5c9739d4a9706fb0ff5718d5743930cc8e7e05ed /Objects
parent4b90c8f17603e7ab4e4568cc8b9d5de4f8099973 (diff)
downloadcpython-git-ec18362f6a7fdc02f9f982872fc1006bca31627d.tar.gz
[3.9] bpo-42083: Allow NULL doc in PyStructSequence_NewType (#25896)
(cherry picked from commit 2f5baa17504feb9a7613bac32fdceed4894434de) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/structseq.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/Objects/structseq.c b/Objects/structseq.c
index b17b1f99a5..5a493c91e8 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -467,12 +467,17 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc)
/* Initialize Slots */
slots[0] = (PyType_Slot){Py_tp_dealloc, (destructor)structseq_dealloc};
slots[1] = (PyType_Slot){Py_tp_repr, (reprfunc)structseq_repr};
- slots[2] = (PyType_Slot){Py_tp_doc, (void *)desc->doc};
- slots[3] = (PyType_Slot){Py_tp_methods, structseq_methods};
- slots[4] = (PyType_Slot){Py_tp_new, structseq_new};
- slots[5] = (PyType_Slot){Py_tp_members, members};
- slots[6] = (PyType_Slot){Py_tp_traverse, (traverseproc)structseq_traverse};
- slots[7] = (PyType_Slot){0, 0};
+ slots[2] = (PyType_Slot){Py_tp_methods, structseq_methods};
+ slots[3] = (PyType_Slot){Py_tp_new, structseq_new};
+ slots[4] = (PyType_Slot){Py_tp_members, members};
+ slots[5] = (PyType_Slot){Py_tp_traverse, (traverseproc)structseq_traverse};
+ if (desc->doc) {
+ slots[6] = (PyType_Slot){Py_tp_doc, (void *)desc->doc};
+ slots[7] = (PyType_Slot){0, 0};
+ }
+ else {
+ slots[6] = (PyType_Slot){0, 0};
+ }
/* Initialize Spec */
/* The name in this PyType_Spec is statically allocated so it is */