mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
Issue #20024: Py_BuildValue() now saves/restores the current exception before
building an item if the build of a previous item failed.
This commit is contained in:
parent
5116f78221
commit
2d854c8e7b
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user