mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
This commit is contained in:
parent
da89b99533
commit
658d513328
3 changed files with 15 additions and 4 deletions
|
@ -527,6 +527,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
|
|||
}
|
||||
|
||||
|
||||
|
||||
PyObject *
|
||||
PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
||||
{
|
||||
|
@ -559,9 +560,15 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
|||
classname = PyString_FromString(dot+1);
|
||||
if (classname == NULL)
|
||||
goto failure;
|
||||
bases = PyTuple_Pack(1, base);
|
||||
if (bases == NULL)
|
||||
goto failure;
|
||||
if (PyTuple_Check(base)) {
|
||||
bases = base;
|
||||
/* INCREF as we create a new ref in the else branch */
|
||||
Py_INCREF(bases);
|
||||
} else {
|
||||
bases = PyTuple_Pack(1, base);
|
||||
if (bases == NULL)
|
||||
goto failure;
|
||||
}
|
||||
result = PyClass_New(bases, dict, classname);
|
||||
failure:
|
||||
Py_XDECREF(bases);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue