mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
python: fix Py_SetPythonHome deprecated API for newer versions
This commit is contained in:
parent
f8c7df8260
commit
9d927c6231
@ -55,11 +55,23 @@ void PythonManager::initPythonHome()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (PY_MAJOR_VERSION <= 3) && (PY_MICRO_VERSION < 11)
|
||||||
if (!customPythonHome.isNull()) {
|
if (!customPythonHome.isNull()) {
|
||||||
qInfo() << "PYTHONHOME =" << customPythonHome;
|
qInfo() << "PYTHONHOME =" << customPythonHome;
|
||||||
pythonHome = Py_DecodeLocale(customPythonHome.toLocal8Bit().constData(), nullptr);
|
pythonHome = Py_DecodeLocale(customPythonHome.toLocal8Bit().constData(), nullptr);
|
||||||
|
|
||||||
|
// This function is deprecated starting from Python 3.11
|
||||||
Py_SetPythonHome(pythonHome);
|
Py_SetPythonHome(pythonHome);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
PyConfig config;
|
||||||
|
PyConfig_InitPythonConfig(&config);
|
||||||
|
|
||||||
|
if (!customPythonHome.isNull()) {
|
||||||
|
qInfo() << "PYTHONHOME =" << customPythonHome;
|
||||||
|
PyConfig_SetBytesString(&config, &config.home, customPythonHome);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
|
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
|
||||||
@ -75,11 +87,20 @@ void PythonManager::initialize()
|
|||||||
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
|
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
|
||||||
PyImport_AppendInittab("CutterBindings", &PyInit_CutterBindings);
|
PyImport_AppendInittab("CutterBindings", &PyInit_CutterBindings);
|
||||||
#endif
|
#endif
|
||||||
|
#if (PY_MAJOR_VERSION <= 3) && (PY_MICRO_VERSION < 11)
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
#else
|
||||||
|
Py_InitializeFromConfig(&config);
|
||||||
|
#endif
|
||||||
// This function is deprecated does nothing starting from Python 3.9
|
// This function is deprecated does nothing starting from Python 3.9
|
||||||
#if (PY_MAJOR_VERSION <= 3) && (PY_MICRO_VERSION < 9)
|
#if (PY_MAJOR_VERSION <= 3) && (PY_MICRO_VERSION < 9)
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (PY_MAJOR_VERSION <= 3) && (PY_MICRO_VERSION >= 11)
|
||||||
|
PyConfig_Clear(&config);
|
||||||
|
#endif
|
||||||
|
|
||||||
pyThreadStateCounter = 1; // we have the thread now => 1
|
pyThreadStateCounter = 1; // we have the thread now => 1
|
||||||
|
|
||||||
RegQtResImporter();
|
RegQtResImporter();
|
||||||
|
Loading…
Reference in New Issue
Block a user