diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-22 14:22:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 14:22:55 (GMT) |
commit | 9a91182d4a87e4511dad20ad101e3eab0e1c5088 (patch) | |
tree | 5b0faaafd4db48a1c57507670457b2192f6299a7 /Modules/_zoneinfo.c | |
parent | 7e3f09cad9b783d8968aa79ff6a8ee57beb8b83e (diff) | |
download | cpython-9a91182d4a87e4511dad20ad101e3eab0e1c5088.zip cpython-9a91182d4a87e4511dad20ad101e3eab0e1c5088.tar.gz cpython-9a91182d4a87e4511dad20ad101e3eab0e1c5088.tar.bz2 |
gh-99537: Use Py_CLEAR() function in C code (#99686)
Replace "Py_XDECREF(var); var = NULL;" with "Py_CLEAR(var);".
Don't replace "Py_DECREF(var); var = NULL;" with "Py_CLEAR(var);". It
would add an useless "if (var)" test in code path where var cannot be
NULL.
Diffstat (limited to 'Modules/_zoneinfo.c')
-rw-r--r-- | Modules/_zoneinfo.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index c0fef13..cb7d4c9 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -231,8 +231,7 @@ zoneinfo_new_instance(PyTypeObject *type, PyObject *key) goto cleanup; error: - Py_XDECREF(self); - self = NULL; + Py_CLEAR(self); cleanup: if (file_obj != NULL) { PyObject *exc, *val, *tb; @@ -2606,14 +2605,9 @@ static PyMethodDef module_methods[] = {{NULL, NULL}}; static void module_free(void *m) { - Py_XDECREF(_tzpath_find_tzfile); - _tzpath_find_tzfile = NULL; - - Py_XDECREF(_common_mod); - _common_mod = NULL; - - Py_XDECREF(io_open); - io_open = NULL; + Py_CLEAR(_tzpath_find_tzfile); + Py_CLEAR(_common_mod); + Py_CLEAR(io_open); xdecref_ttinfo(&NO_TTINFO); |