From 303de6a25b4dc4874eded29c34c719a3bd6a4f40 Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Thu, 20 Apr 2006 22:42:37 +0000 Subject: Fix (and add test for) missing check for BaseException subclasses in the C API. --- Python/errors.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Python/errors.c') 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); -- cgit v1.2.1