mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
Fix (and add test for) missing check for BaseException subclasses in the C
API.
This commit is contained in:
parent
4f564bd68a
commit
303de6a25b
2 changed files with 28 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue