Skip to content

Commit

Permalink
bpo-41336: Fix the error handling in zoneinfo_new_instance() (pythonG…
Browse files Browse the repository at this point in the history
…H-21546)

Do not call PyObject_CallMethod() with a live exception (like
KeyboardInterrupt).
  • Loading branch information
ZackerySpytz authored and shihai1991 committed Aug 20, 2020
1 parent f202008 commit 71123d7
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 71123d7

Please sign in to comment.