summaryrefslogtreecommitdiffstats
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-02-28 11:50:52 (GMT)
committerGitHub <noreply@github.com>2023-02-28 11:50:52 (GMT)
commit4c87537efb5fd28b4e4ee9631076ed5953720156 (patch)
tree8c8bf4b1c849bc47dc28561d0653c95b33e357db /Python/modsupport.c
parent85b1fc1fc5a2e49d521382eaf5e7793175d00371 (diff)
downloadcpython-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.c14
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);