bpo-39877: PyGILState_Ensure() don't call PyEval_InitThreads() (GH-18891)

PyGILState_Ensure() doesn't call PyEval_InitThreads() anymore when a
new Python thread state is created. The GIL is created by
Py_Initialize() since Python 3.7, it's not needed to call
PyEval_InitThreads() explicitly.

Add an assertion to ensure that the GIL is already created.
This commit is contained in:
Victor Stinner 2020-03-10 00:37:48 +01:00 committed by GitHub
parent addaaaa946
commit 175a704abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 20 deletions

View file

@ -198,11 +198,17 @@ ensure_tstate_not_null(const char *func, PyThreadState *tstate)
}
int
_PyEval_ThreadsInitialized(_PyRuntimeState *runtime)
{
return gil_created(&runtime->ceval.gil);
}
int
PyEval_ThreadsInitialized(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
return gil_created(&runtime->ceval.gil);
return _PyEval_ThreadsInitialized(runtime);
}
PyStatus