10000 Chain exceptions during cleanup. · python/cpython@678aed8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 678aed8

Browse files
Chain exceptions during cleanup.
1 parent 7c4dae2 commit 678aed8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/_interpretersmodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@ _run_string_in_main(PyInterpreterState *interp, const char *codestr,
180180
}
181181

182182
// Restore __main__.
183+
PyObject *exc = NULL, *value = NULL, *tb = NULL;
184+
PyErr_Fetch(&exc, &value, &tb);
183185
if (PyMapping_SetItemString(interp->modules, "__main__", main_mod) < 0) {
184-
// XXX Chain exceptions...
185-
//PyErr_Restore(exc, value, tb);
186+
_PyErr_ChainExceptions(exc, value, tb);
187+
} else {
188+
PyErr_Restore(exc, value, tb);
186189
}
187190
Py_DECREF(main_mod);
188191

0 commit comments

Comments
 (0)
0