From: Ovidiu Mircescu Date: Wed, 1 Mar 2023 14:38:26 +0000 (+0100) Subject: PyInterp for python >3.8 X-Git-Tag: V9_11_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fgui.git;a=commitdiff_plain;h=370f3e5fe29e05f598c86b684c5b0684c4411af3 PyInterp for python >3.8 Patch from Phimeca. --- diff --git a/tools/PyConsole/src/PyConsole_Editor.h b/tools/PyConsole/src/PyConsole_Editor.h index 451a79f97..0748cf1e6 100644 --- a/tools/PyConsole/src/PyConsole_Editor.h +++ b/tools/PyConsole/src/PyConsole_Editor.h @@ -38,7 +38,7 @@ class QEventLoop; class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit { - Q_OBJECT; + Q_OBJECT public: PyConsole_Editor( QWidget* = 0 ); diff --git a/tools/PyInterp/src/PyInterp_Interp.cxx b/tools/PyInterp/src/PyInterp_Interp.cxx index 287f6400e..6ad2fe9af 100644 --- a/tools/PyInterp/src/PyInterp_Interp.cxx +++ b/tools/PyInterp/src/PyInterp_Interp.cxx @@ -268,10 +268,19 @@ void PyInterp_Interp::initPython() { changed_argv[i] = Py_DecodeLocale(_argv[i], NULL); } - + +#if PY_VERSION_HEX < 0x03080000 Py_SetProgramName(changed_argv[0]); Py_Initialize(); // Initialize the interpreter PySys_SetArgv(_argc, changed_argv); +#else + PyConfig config; + PyConfig_InitPythonConfig(&config); + PyStatus status = PyConfig_SetString(&config, &config.program_name, changed_argv[0]); + status = PyConfig_SetArgv(&config, _argc, changed_argv); + status = Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); +#endif #if PY_VERSION_HEX < 0x03070000 PyEval_InitThreads(); // Create (and acquire) the Python global interpreter lock (GIL)