mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-31091: Remove dead code in PyErr_GivenExceptionMatches(). (#2963)
According to the comment, there was previously a call to PyObject_IsSubclass() involved which could fail, but since it was replaced with a call to PyType_IsSubtype(), it can no longer fail.
This commit is contained in:
parent
8474d87165
commit
e4c06bcca3
1 changed files with 1 additions and 13 deletions
|
@ -191,19 +191,7 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc)
|
||||||
err = PyExceptionInstance_Class(err);
|
err = PyExceptionInstance_Class(err);
|
||||||
|
|
||||||
if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) {
|
if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) {
|
||||||
int res = 0;
|
return PyType_IsSubtype((PyTypeObject *)err, (PyTypeObject *)exc);
|
||||||
PyObject *exception, *value, *tb;
|
|
||||||
PyErr_Fetch(&exception, &value, &tb);
|
|
||||||
/* PyObject_IsSubclass() can recurse and therefore is
|
|
||||||
not safe (see test_bad_getattr in test.pickletester). */
|
|
||||||
res = PyType_IsSubtype((PyTypeObject *)err, (PyTypeObject *)exc);
|
|
||||||
/* This function must not fail, so print the error here */
|
|
||||||
if (res == -1) {
|
|
||||||
PyErr_WriteUnraisable(err);
|
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
PyErr_Restore(exception, value, tb);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err == exc;
|
return err == exc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue