bpo-45711: remove unnecessary DUP_TOP and POP in exception handling (GH-29495)

This commit is contained in:
Irit Katriel 2021-11-10 18:08:28 +00:00 committed by GitHub
parent 05fbd60147
commit 4cdeee5978
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 97 deletions

View file

@ -3907,7 +3907,7 @@ check_eval_breaker:
"inherit from BaseException is not "
"allowed";
PyObject *right = POP();
PyObject *left = POP();
PyObject *left = TOP();
if (PyTuple_Check(right)) {
Py_ssize_t i, length;
length = PyTuple_GET_SIZE(right);
@ -3916,7 +3916,6 @@ check_eval_breaker:
if (!PyExceptionClass_Check(exc)) {
_PyErr_SetString(tstate, PyExc_TypeError,
cannot_catch_msg);
Py_DECREF(left);
Py_DECREF(right);
goto error;
}
@ -3926,13 +3925,11 @@ check_eval_breaker:
if (!PyExceptionClass_Check(right)) {
_PyErr_SetString(tstate, PyExc_TypeError,
cannot_catch_msg);
Py_DECREF(left);
Py_DECREF(right);
goto error;
}
}
int res = PyErr_GivenExceptionMatches(left, right);
Py_DECREF(left);
Py_DECREF(right);
if (res > 0) {
/* Exception matches -- Do nothing */;