Skip to content

Commit 1637eb9

Browse files
committed
Increase mutex protect region
1 parent 67cf8fd commit 1637eb9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Modules/_datetimemodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7336,6 +7336,8 @@ init_static_types(PyInterpreterState *interp, int reloading)
73367336
return 0;
73377337
}
73387338

7339+
static PyMutex mutex = {0};
7340+
PyMutex_Lock(&mutex);
73397341
// `&...` is not a constant expression according to a strict reading
73407342
// of C standards. Fill tp_base at run-time rather than statically.
73417343
// See https://bugs.python.org/issue40777
@@ -7344,17 +7346,16 @@ init_static_types(PyInterpreterState *interp, int reloading)
73447346

73457347
/* Bases classes must be initialized before subclasses,
73467348
* so capi_types must have the types in the appropriate order. */
7347-
static PyMutex mutex = {0};
73487349
for (size_t i = 0; i < Py_ARRAY_LENGTH(capi_types); i++) {
73497350
PyTypeObject *type = capi_types[i];
7350-
PyMutex_Lock(&mutex);
73517351
int ret = _PyStaticType_InitForExtension(interp, type);
7352-
PyMutex_Unlock(&mutex);
73537352
if (ret < 0) {
7353+
PyMutex_Unlock(&mutex);
73547354
return -1;
73557355
}
73567356
}
73577357

7358+
PyMutex_Unlock(&mutex);
73587359
return 0;
73597360
}
73607361

0 commit comments

Comments
 (0)