From: Ovidiu MIRCESCU Date: Tue, 6 Apr 2021 11:23:24 +0000 (+0200) Subject: For future compatibility with python 3.9. X-Git-Tag: V9_7_0a1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5eebb77d32875c1f953b95506416e23a0c96204e;p=modules%2Fgui.git For future compatibility with python 3.9. see https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads --- 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 } }