diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-07-20 12:51:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 12:51:26 (GMT) |
commit | eca2549f5a5048b44ca88b9555f1c62f094e3c12 (patch) | |
tree | 9e0b70d99f39ac5f7cbb09f59e54e04291f6b0af /Modules/_zoneinfo.c | |
parent | f9bf0157999cb4adbcfd7e9bf526bfa48601e128 (diff) | |
download | cpython-eca2549f5a5048b44ca88b9555f1c62f094e3c12.zip cpython-eca2549f5a5048b44ca88b9555f1c62f094e3c12.tar.gz cpython-eca2549f5a5048b44ca88b9555f1c62f094e3c12.tar.bz2 |
bpo-41336: Fix the error handling in zoneinfo_new_instance() (GH-21546)
Do not call PyObject_CallMethod() with a live exception (like
KeyboardInterrupt).
Diffstat (limited to 'Modules/_zoneinfo.c')
-rw-r--r-- | Modules/_zoneinfo.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 319d6c7..bee84cb 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -224,8 +224,14 @@ error: 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); |