diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-11-22 11:25:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 11:25:02 (GMT) |
commit | 686c203cd4355be5b7809a9d24b4aa3566d9371f (patch) | |
tree | 457b1a741d4f70e85d2bea686cd9ffb822cd8a85 /Objects | |
parent | c4d45ee670c09d4f6da709df072ec80cb7dfad22 (diff) | |
download | cpython-686c203cd4355be5b7809a9d24b4aa3566d9371f.zip cpython-686c203cd4355be5b7809a9d24b4aa3566d9371f.tar.gz cpython-686c203cd4355be5b7809a9d24b4aa3566d9371f.tar.bz2 |
bpo-42423: Accept single base class in PyType_FromModuleAndSpec() (GH-23441)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/structseq.c | 9 | ||||
-rw-r--r-- | Objects/typeobject.c | 5 |
2 files changed, 4 insertions, 10 deletions
diff --git a/Objects/structseq.c b/Objects/structseq.c index 5caa3bd..bb28e11 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -492,7 +492,6 @@ PyTypeObject * PyStructSequence_NewType(PyStructSequence_Desc *desc) { PyMemberDef *members; - PyObject *bases; PyTypeObject *type; PyType_Slot slots[8]; PyType_Spec spec; @@ -526,13 +525,7 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc) spec.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC; spec.slots = slots; - bases = PyTuple_Pack(1, &PyTuple_Type); - if (bases == NULL) { - PyMem_FREE(members); - return NULL; - } - type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, bases); - Py_DECREF(bases); + type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type); PyMem_FREE(members); if (type == NULL) { return NULL; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9ebeeeb..3a6143a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2993,8 +2993,9 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) } } else if (!PyTuple_Check(bases)) { - PyErr_SetString(PyExc_SystemError, "bases is not a tuple"); - goto fail; + bases = PyTuple_Pack(1, bases); + if (!bases) + goto fail; } else { Py_INCREF(bases); |