Skip to content

Commit 4b1e45e

Browse files
gh-83004: Clean up refleak in _zoneinfo initialisation (GH-98842)
(cherry picked from commit 31f2f65) Co-authored-by: Shantanu <[email protected]>
1 parent be4bab8 commit 4b1e45e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clean up refleak on failed module initialisation in :mod:`_zoneinfo`

Modules/_zoneinfo.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -2652,8 +2652,9 @@ zoneinfomodule_exec(PyObject *m)
26522652
goto error;
26532653
}
26542654

2655-
Py_INCREF(&PyZoneInfo_ZoneInfoType);
2656-
PyModule_AddObject(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType);
2655+
if (PyModule_AddObjectRef(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType) < 0) {
2656+
goto error;
2657+
}
26572658

26582659
/* Populate imports */
26592660
PyObject *_tzpath_module = PyImport_ImportModule("zoneinfo._tzpath");

0 commit comments

Comments
 (0)