[Python-checkins] gh-83004: Clean up refleak in _zoneinfo initialisation (GH-98842)
miss-islington
webhook-mailer at python.org
Sun Nov 6 09:30:47 EST 2022
https://github.com/python/cpython/commit/4b1e45e78b3f8bc9be7497311cfa36e762f43226
commit: 4b1e45e78b3f8bc9be7497311cfa36e762f43226
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-11-06T06:30:41-08:00
summary:
gh-83004: Clean up refleak in _zoneinfo initialisation (GH-98842)
(cherry picked from commit 31f2f6568d89564cc1d686cd6b75ba5578aaa748)
Co-authored-by: Shantanu <12621235+hauntsaninja at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst
M Modules/_zoneinfo.c
diff --git a/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst b/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst
new file mode 100644
index 000000000000..bd54d3eae8c9
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst
@@ -0,0 +1 @@
+Clean up refleak on failed module initialisation in :mod:`_zoneinfo`
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 1535721b026d..55975f4e2691 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2652,8 +2652,9 @@ zoneinfomodule_exec(PyObject *m)
goto error;
}
- Py_INCREF(&PyZoneInfo_ZoneInfoType);
- PyModule_AddObject(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType);
+ if (PyModule_AddObjectRef(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType) < 0) {
+ goto error;
+ }
/* Populate imports */
PyObject *_tzpath_module = PyImport_ImportModule("zoneinfo._tzpath");
More information about the Python-checkins
mailing list