[Python-checkins] gh-83004: Clean up refleak in _zoneinfo initialisation (#98842)
JelleZijlstra
webhook-mailer at python.org
Sun Nov 6 09:04:41 EST 2022
https://github.com/python/cpython/commit/31f2f6568d89564cc1d686cd6b75ba5578aaa748
commit: 31f2f6568d89564cc1d686cd6b75ba5578aaa748
branch: main
author: Shantanu <12621235+hauntsaninja at users.noreply.github.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-11-06T06:04:36-08:00
summary:
gh-83004: Clean up refleak in _zoneinfo initialisation (#98842)
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 36b25bf3c054..9986b9111177 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2657,8 +2657,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 */
_tzpath_find_tzfile =
More information about the Python-checkins
mailing list