Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 37871:a47117fa3ca8
Fix (and add test for) missing check for BaseException subclasses in the C
API.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Thu, 20 Apr 2006 22:42:37 +0000 |
| parents | 49c6eb688906 |
| children | f731859e9b3b |
line wrap: on
line diff
--- a/Python/errors.c Thu Apr 20 22:36:57 2006 +0000 +++ b/Python/errors.c Thu Apr 20 22:42:37 2006 +0000 @@ -47,6 +47,15 @@ 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);
