summaryrefslogtreecommitdiff
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2018-01-29 11:57:45 +0100
committerGitHub <noreply@github.com>2018-01-29 11:57:45 +0100
commit2914bb32e2adf8dff77c0ca58b33201bc94e398c (patch)
tree1a2e9e064f9dbc362c2b3c5bbb52affadaa448fa /Python/pylifecycle.c
parent8997f9cd1a59f04fbb8c7b590295a9f38c548744 (diff)
downloadcpython-git-2914bb32e2adf8dff77c0ca58b33201bc94e398c.tar.gz
bpo-20891: Py_Initialize() now creates the GIL (#4700)
The GIL is no longer created "on demand" to fix a race condition when PyGILState_Ensure() is called in a non-Python thread.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index d46784a2f6..82ab915425 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -681,9 +681,13 @@ _Py_InitializeCore(const _PyCoreConfig *core_config)
Instead we destroy the previously created GIL here, which ensures
that we can call Py_Initialize / Py_FinalizeEx multiple times. */
_PyEval_FiniThreads();
+
/* Auto-thread-state API */
_PyGILState_Init(interp, tstate);
+ /* Create the GIL */
+ PyEval_InitThreads();
+
_Py_ReadyTypes();
if (!_PyFrame_Init())