summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-20 22:42:37 (GMT)
committerThomas Wouters <thomas@python.org>2006-04-20 22:42:37 (GMT)
commit303de6a25b4dc4874eded29c34c719a3bd6a4f40 (patch)
tree09598a8bf4f8353de8b3c1e728eea522803b39a1 /Python/errors.c
parent4f564bd68a5bf3e22c81c0c74f0e781fa0d3f70a (diff)
downloadcpython-303de6a25b4dc4874eded29c34c719a3bd6a4f40.zip
cpython-303de6a25b4dc4874eded29c34c719a3bd6a4f40.tar.gz
cpython-303de6a25b4dc4874eded29c34c719a3bd6a4f40.tar.bz2
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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index a64900b..67f86ed 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);