mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
port 8d05f697acd4 (#11627)
This commit is contained in:
parent
2659140a5d
commit
c3349cd22e
3 changed files with 21 additions and 2 deletions
|
@ -3515,9 +3515,17 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
|
|||
Py_DECREF(tmp);
|
||||
}
|
||||
|
||||
if (PyExceptionClass_Check(type))
|
||||
if (PyExceptionClass_Check(type)) {
|
||||
PyErr_NormalizeException(&type, &value, &tb);
|
||||
|
||||
if (!PyExceptionInstance_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"calling %s() should have returned an instance of "
|
||||
"BaseException, not '%s'",
|
||||
((PyTypeObject *)type)->tp_name,
|
||||
Py_TYPE(value)->tp_name);
|
||||
goto raise_error;
|
||||
}
|
||||
}
|
||||
else if (PyExceptionInstance_Check(type)) {
|
||||
/* Raising an instance. The value should be a dummy. */
|
||||
if (value != Py_None) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue