Skip to content

Commit

Permalink
bpo-41336: Fix the error handling in zoneinfo_new_instance() (GH-21546)
Browse files Browse the repository at this point in the history
Do not call PyObject_CallMethod() with a live exception (like
KeyboardInterrupt).
(cherry picked from commit eca2549)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
  • Loading branch information
miss-islington and ZackerySpytz committed Jul 20, 2020
1 parent 663f827 commit add7cfc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,14 @@ zoneinfo_new_instance(PyTypeObject *type, PyObject *key)
self = NULL;
cleanup:
if (file_obj != NULL) {
PyObject *exc, *val, *tb;
PyErr_Fetch(&exc, &val, &tb);
PyObject *tmp = PyObject_CallMethod(file_obj, "close", NULL);
Py_DECREF(tmp);
_PyErr_ChainExceptions(exc, val, tb);
if (tmp == NULL) {
Py_CLEAR(self);
}
Py_XDECREF(tmp);
Py_DECREF(file_obj);
}
Py_DECREF(file_path);
Expand Down

0 comments on commit add7cfc

Please sign in to comment.