]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-119655: Fix reference leak in the ``_datetimemodule.c`` (gh-119713)
authorKirill Podoprigora <kirill.bast9@mail.ru>
Wed, 29 May 2024 15:43:03 +0000 (18:43 +0300)
committerGitHub <noreply@github.com>
Wed, 29 May 2024 15:43:03 +0000 (09:43 -0600)
Modules/_datetimemodule.c

index b72a5d3c70b92a3ad1b9d701ba0a51ec1b4756cc..466382b5148509dd132ac92adcd582499604e954 100644 (file)
@@ -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;
     }