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

This commit is contained in:
Irit Katriel 2023-02-28 11:50:52 +00:00 committed by GitHub
parent 85b1fc1fc5
commit 4c87537efb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 72 deletions

View file

@ -1633,8 +1633,7 @@ static void
compiler_exit_scope(struct compiler *c)
{
// Don't call PySequence_DelItem() with an exception raised
PyObject *exc_type, *exc_val, *exc_tb;
PyErr_Fetch(&exc_type, &exc_val, &exc_tb);
PyObject *exc = PyErr_GetRaisedException();
c->c_nestlevel--;
compiler_unit_free(c->u);
@ -1655,7 +1654,7 @@ compiler_exit_scope(struct compiler *c)
c->u = NULL;
}
PyErr_Restore(exc_type, exc_val, exc_tb);
PyErr_SetRaisedException(exc);
}
/* Search if variable annotations are present statically in a block. */