gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Modules/) (#102196)

This commit is contained in:
Irit Katriel 2023-02-24 21:43:03 +00:00 committed by GitHub
parent 568fc0dee4
commit 2db23d10bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 136 additions and 169 deletions

View file

@ -5175,10 +5175,9 @@ static void
sock_finalize(PySocketSockObject *s)
{
SOCKET_T fd;
PyObject *error_type, *error_value, *error_traceback;
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
PyObject *exc = PyErr_GetRaisedException();
if (s->sock_fd != INVALID_SOCKET) {
if (PyErr_ResourceWarning((PyObject *)s, 1, "unclosed %R", s)) {
@ -5202,7 +5201,7 @@ sock_finalize(PySocketSockObject *s)
}
/* Restore the saved exception. */
PyErr_Restore(error_type, error_value, error_traceback);
PyErr_SetRaisedException(exc);
}
static void