From 5eebb77d32875c1f953b95506416e23a0c96204e Mon Sep 17 00:00:00 2001 From: Ovidiu MIRCESCU Date: Tue, 6 Apr 2021 13:23:24 +0200 Subject: [PATCH] For future compatibility with python 3.9. see https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads --- src/SUITApp/SUITApp_init_python.cxx | 2 ++ tools/PyInterp/src/PyInterp_Interp.cxx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/SUITApp/SUITApp_init_python.cxx b/src/SUITApp/SUITApp_init_python.cxx index 2959c7a80..5042ef8ac 100644 --- a/src/SUITApp/SUITApp_init_python.cxx +++ b/src/SUITApp/SUITApp_init_python.cxx @@ -69,7 +69,9 @@ void SUIT_PYTHON::init_python(int argc, char **argv) script += "del _custom_except_hook, sys\n"; PyRun_SimpleString(qUtf8Printable(script)); // VSR (22/09/2016): end of workaround +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); // Create (and acquire) the interpreter lock - can be called many times +#endif // Py_InitThreads acquires the GIL PyThreadState *pts = PyGILState_GetThisThreadState(); PyEval_ReleaseThread(pts); diff --git a/tools/PyInterp/src/PyInterp_Interp.cxx b/tools/PyInterp/src/PyInterp_Interp.cxx index 4620bb373..6f0344630 100644 --- a/tools/PyInterp/src/PyInterp_Interp.cxx +++ b/tools/PyInterp/src/PyInterp_Interp.cxx @@ -273,7 +273,9 @@ void PyInterp_Interp::initPython() Py_Initialize(); // Initialize the interpreter PySys_SetArgv(_argc, changed_argv); +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); // Create (and acquire) the Python global interpreter lock (GIL) +#endif PyEval_SaveThread(); // release safely GIL } } -- 2.39.2