diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-21 19:52:17 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-21 19:52:17 (GMT) |
commit | 2d854c8e7b14d17d7b0d1508c193fe3db92dd215 (patch) | |
tree | 21f5fc6029a8cdf7f1e6a8b694ce18cf49031baf /Python/modsupport.c | |
parent | 5116f782217551012942b1f44393cc9e9e3941da (diff) | |
download | cpython-2d854c8e7b14d17d7b0d1508c193fe3db92dd215.zip cpython-2d854c8e7b14d17d7b0d1508c193fe3db92dd215.tar.gz cpython-2d854c8e7b14d17d7b0d1508c193fe3db92dd215.tar.bz2 |
Issue #20024: Py_BuildValue() now saves/restores the current exception before
building an item if the build of a previous item failed.
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r-- | Python/modsupport.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c index 428914f..6c938dd 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -161,7 +161,17 @@ do_mktuple(const char **p_format, va_list *p_va, int endchar, int n, int flags) /* Note that we can't bail immediately on error as this will leak refcounts on any 'N' arguments. */ for (i = 0; i < n; i++) { - PyObject *w = do_mkvalue(p_format, p_va, flags); + PyObject *w; + + if (itemfailed) { + PyObject *exception, *value, *tb; + PyErr_Fetch(&exception, &value, &tb); + w = do_mkvalue(p_format, p_va, flags); + PyErr_Restore(exception, value, tb); + } + else { + w = do_mkvalue(p_format, p_va, flags); + } if (w == NULL) { itemfailed = 1; Py_INCREF(Py_None); |