mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
This commit is contained in:
parent
1f0ccfa853
commit
5afa03a72e
3 changed files with 19 additions and 0 deletions
|
@ -3413,6 +3413,13 @@ do_raise(PyObject *exc, PyObject *cause)
|
|||
value = PyObject_CallObject(exc, NULL);
|
||||
if (value == NULL)
|
||||
goto raise_error;
|
||||
if (!PyExceptionInstance_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"calling %R should have returned an instance of "
|
||||
"BaseException, not %R",
|
||||
type, Py_TYPE(value));
|
||||
goto raise_error;
|
||||
}
|
||||
}
|
||||
else if (PyExceptionInstance_Check(exc)) {
|
||||
value = exc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue