diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-02-28 11:50:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 11:50:52 (GMT) |
commit | 4c87537efb5fd28b4e4ee9631076ed5953720156 (patch) | |
tree | 8c8bf4b1c849bc47dc28561d0653c95b33e357db /Python/modsupport.c | |
parent | 85b1fc1fc5a2e49d521382eaf5e7793175d00371 (diff) | |
download | cpython-4c87537efb5fd28b4e4ee9631076ed5953720156.zip cpython-4c87537efb5fd28b4e4ee9631076ed5953720156.tar.gz cpython-4c87537efb5fd28b4e4ee9631076ed5953720156.tar.bz2 |
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (#102193)
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r-- | Python/modsupport.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c index b9a10dc..7569845 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -93,16 +93,12 @@ static PyObject *do_mkvalue(const char**, va_list *, int); static void do_ignore(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags) { - PyObject *v; - Py_ssize_t i; assert(PyErr_Occurred()); - v = PyTuple_New(n); - for (i = 0; i < n; i++) { - PyObject *exception, *value, *tb, *w; - - PyErr_Fetch(&exception, &value, &tb); - w = do_mkvalue(p_format, p_va, flags); - PyErr_Restore(exception, value, tb); + PyObject *v = PyTuple_New(n); + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *exc = PyErr_GetRaisedException(); + PyObject *w = do_mkvalue(p_format, p_va, flags); + PyErr_SetRaisedException(exc); if (w != NULL) { if (v != NULL) { PyTuple_SET_ITEM(v, i, w); |