From: Ovidiu MIRCESCU Date: Tue, 6 Apr 2021 11:22:11 +0000 (+0200) Subject: For future compatibility with python 3.9. X-Git-Tag: V9_7_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28ccecc39947373ea231ff46a3d0c9a5c2448bc3;p=modules%2Fkernel.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/Container/Container_init_python.cxx b/src/Container/Container_init_python.cxx index 25607af34..4baf0d1e1 100644 --- a/src/Container/Container_init_python.cxx +++ b/src/Container/Container_init_python.cxx @@ -202,8 +202,9 @@ void KERNEL_PYTHON::init_python(int argc, char **argv) script += "del _custom_except_hook, sys\n"; PyRun_SimpleString(script.c_str()); // VSR (22/09/2016): end of workaround +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); // Create (and acquire) the interpreter lock - +#endif // Create python objects to capture stdout and stderr PyObject* _vout=(PyObject*)ContainerNewPyStdOut( false ); // stdout PyObject* _verr=(PyObject*)ContainerNewPyStdOut( true ); // stderr diff --git a/src/Container/SALOME_CPythonHelper.cxx b/src/Container/SALOME_CPythonHelper.cxx index b677d4fa9..d6b5585e9 100644 --- a/src/Container/SALOME_CPythonHelper.cxx +++ b/src/Container/SALOME_CPythonHelper.cxx @@ -36,7 +36,9 @@ Py_DecodeLocale(const char *arg, size_t *size) void SALOME_CPythonHelper::initializePython(int argc, char *argv[]) { Py_Initialize(); +#if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); +#endif wchar_t **changed_argv = new wchar_t*[argc]; // Setting arguments for (int i = 0; i < argc; i++) changed_argv[i] = Py_DecodeLocale(argv[i], NULL);