diff options
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-11-02-05-54-02.gh-issue-83004.0v8iyw.rst | 1 | ||||
-rw-r--r-- | Modules/_zoneinfo.c | 5 |
2 files changed, 4 insertions, 2 deletions
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 0000000..bd54d3e --- /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 36b25bf..9986b91 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 = |