Skip to content

Commit 34f9b3e

Browse files
authored
gh-119655: Fix reference leak in the _datetimemodule.c (gh-119713)
1 parent 1f481fd commit 34f9b3e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/_datetimemodule.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -6972,10 +6972,13 @@ _datetime_exec(PyObject *module)
69726972
} while (0)
69736973

69746974
PyTypeObject *PyDateTime_IsoCalendarDateType = NULL;
6975-
CREATE_TYPE(PyDateTime_IsoCalendarDateType, &isocal_spec, &PyTuple_Type);
6975+
datetime_state *st = get_datetime_state();
6976+
6977+
if (!st->initialized) {
6978+
CREATE_TYPE(PyDateTime_IsoCalendarDateType, &isocal_spec, &PyTuple_Type);
6979+
}
69766980
#undef CREATE_TYPE
69776981

6978-
datetime_state *st = get_datetime_state();
69796982
if (init_state(st, PyDateTime_IsoCalendarDateType) < 0) {
69806983
goto error;
69816984
}

0 commit comments

Comments
 (0)