diff options
author | Kirill Podoprigora <kirill.bast9@mail.ru> | 2024-05-29 15:43:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 15:43:03 (GMT) |
commit | 34f9b3e7244615d2372614b20e10250e68cc8e61 (patch) | |
tree | c68b3469d533b613a47bccbedc65856ffcc66f00 | |
parent | 1f481fd3275dbc12a88c16129621de19ea20e4ca (diff) | |
download | cpython-34f9b3e7244615d2372614b20e10250e68cc8e61.zip cpython-34f9b3e7244615d2372614b20e10250e68cc8e61.tar.gz cpython-34f9b3e7244615d2372614b20e10250e68cc8e61.tar.bz2 |
gh-119655: Fix reference leak in the ``_datetimemodule.c`` (gh-119713)
-rw-r--r-- | Modules/_datetimemodule.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b72a5d3..466382b 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -6972,10 +6972,13 @@ _datetime_exec(PyObject *module) } while (0) PyTypeObject *PyDateTime_IsoCalendarDateType = NULL; - CREATE_TYPE(PyDateTime_IsoCalendarDateType, &isocal_spec, &PyTuple_Type); + datetime_state *st = get_datetime_state(); + + if (!st->initialized) { + CREATE_TYPE(PyDateTime_IsoCalendarDateType, &isocal_spec, &PyTuple_Type); + } #undef CREATE_TYPE - datetime_state *st = get_datetime_state(); if (init_state(st, PyDateTime_IsoCalendarDateType) < 0) { goto error; } |