diff options
author | Georg Brandl <georg@python.org> | 2006-05-23 11:17:21 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-23 11:17:21 (GMT) |
commit | 658d5133285ccf32184ad8cc2899dfe3440aea2d (patch) | |
tree | e46bb429b43802a601441338a2d3d194a0bbc43b /Python/errors.c | |
parent | da89b99533e4239344a4e31067e26325ae2b4c1a (diff) | |
download | cpython-658d5133285ccf32184ad8cc2899dfe3440aea2d.zip cpython-658d5133285ccf32184ad8cc2899dfe3440aea2d.tar.gz cpython-658d5133285ccf32184ad8cc2899dfe3440aea2d.tar.bz2 |
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Python/errors.c b/Python/errors.c index 8327f53..baf52ff 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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); |