diff options
author | Thomas Wouters <thomas@python.org> | 2006-04-20 22:42:37 +0000 |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-04-20 22:42:37 +0000 |
commit | 3294dd7ef0ec5f6fb41d8bbc1eb7d281fe283afd (patch) | |
tree | 121a81cdb553a8d0b9df6e991625a772e882ad30 /Python/errors.c | |
parent | 84baa28cbd054371a1e700e009e7dffc2c0d2b34 (diff) | |
download | cpython-3294dd7ef0ec5f6fb41d8bbc1eb7d281fe283afd.tar.gz |
Fix (and add test for) missing check for BaseException subclasses in the C
API.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index a64900bfd2..67f86ed36c 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -47,6 +47,15 @@ PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) void PyErr_SetObject(PyObject *exception, PyObject *value) { + if (exception != NULL && + !PyExceptionClass_Check(exception)) { + PyObject *excstr = PyObject_Repr(exception); + PyErr_Format(PyExc_SystemError, + "exception %s not a BaseException subclass", + PyString_AS_STRING(excstr)); + Py_DECREF(excstr); + return; + } Py_XINCREF(exception); Py_XINCREF(value); PyErr_Restore(exception, value, (PyObject *)NULL); |