From 28ccecc39947373ea231ff46a3d0c9a5c2448bc3 Mon Sep 17 00:00:00 2001 From: Ovidiu MIRCESCU Date: Tue, 6 Apr 2021 13:22:11 +0200 Subject: [PATCH] For future compatibility with python 3.9. see https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads --- src/Container/Container_init_python.cxx | 3 ++- src/Container/SALOME_CPythonHelper.cxx | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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); -- 2.39.2