diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-09 23:22:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-09 23:22:10 (GMT) |
commit | 8c4cf96a06e2483a11a4cb34c550df5bd22f990b (patch) | |
tree | 8d9cca204b25e1f0fa4c1ab610ac34d989dc3561 /Modules | |
parent | 4fbbf699c0d72f6db62484c88a05c826c3703eb5 (diff) | |
download | cpython-8c4cf96a06e2483a11a4cb34c550df5bd22f990b.zip cpython-8c4cf96a06e2483a11a4cb34c550df5bd22f990b.tar.gz cpython-8c4cf96a06e2483a11a4cb34c550df5bd22f990b.tar.bz2 |
[3.12] gh-105375: Improve error handling in `zoneinfo` module (GH-105586) (#105612)
Fix bugs where exceptions could end up being overwritten
because of deferred error handling.
(cherry picked from commit 33c92c4f15539806c8aff8574ff30a8b307e3e4d)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_zoneinfo.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index c8c791b..38b806c 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -694,14 +694,19 @@ zoneinfo_fromutc(PyObject *obj_self, PyObject *dt) } else { PyObject *replace = PyObject_GetAttrString(tmp, "replace"); + Py_DECREF(tmp); + if (replace == NULL) { + return NULL; + } PyObject *args = PyTuple_New(0); + if (args == NULL) { + Py_DECREF(replace); + return NULL; + } PyObject *kwargs = PyDict_New(); - - Py_DECREF(tmp); - if (args == NULL || kwargs == NULL || replace == NULL) { - Py_XDECREF(args); - Py_XDECREF(kwargs); - Py_XDECREF(replace); + if (kwargs == NULL) { + Py_DECREF(replace); + Py_DECREF(args); return NULL; } |