Skip to content

Commit 70006d6

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 92cc215 commit 70006d6

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
@@ -2648,8 +2648,9 @@ zoneinfomodule_exec(PyObject *m)
26482648
goto error;
26492649
}
26502650

2651-
Py_INCREF(&PyZoneInfo_ZoneInfoType);
2652-
PyModule_AddObject(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType);
2651+
if (PyModule_AddObjectRef(m, "ZoneInfo", (PyObject *)&PyZoneInfo_ZoneInfoType) < 0) {
2652+
goto error;
2653+
}
26532654

26542655
/* Populate imports */
26552656
PyObject *_tzpath_module = PyImport_ImportModule("zoneinfo._tzpath");

0 commit comments

Comments
 (0)