[Python-checkins] cpython: Issue #20024: Py_BuildValue() now saves/restores the current exception before
victor.stinner
python-checkins at python.org
Tue Jan 21 20:55:50 CET 2014
http://hg.python.org/cpython/rev/29b4eb47f65e
changeset: 88613:29b4eb47f65e
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jan 21 20:52:17 2014 +0100
summary:
Issue #20024: Py_BuildValue() now saves/restores the current exception before
building an item if the build of a previous item failed.
files:
Python/modsupport.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Python/modsupport.c b/Python/modsupport.c
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -161,7 +161,17 @@
/* 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);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list