Salome HOME
PyInterp for python >3.8
[modules/gui.git] / tools / PyInterp / src / PyInterp_Interp.cxx
index 287f6400e0b834bc34c4bbc4fdb0c11f4c5f0bce..6ad2fe9afce71c1b069d1d366e8b55852e8d33c5 100644 (file)
@@ -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)