diff options
Diffstat (limited to 'Plugins/ScriptingPython')
| -rw-r--r-- | Plugins/ScriptingPython/scriptingpython.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Plugins/ScriptingPython/scriptingpython.cpp b/Plugins/ScriptingPython/scriptingpython.cpp index 1dedb5c..a8de694 100644 --- a/Plugins/ScriptingPython/scriptingpython.cpp +++ b/Plugins/ScriptingPython/scriptingpython.cpp @@ -582,15 +582,25 @@ SqlQueryPtr ScriptingPython::dbCommonEval(PyObject* sqlArg, const char* fnName) QVariant ScriptingPython::getVariable(const QString& name) { PyThreadState* state = PyThreadState_Get(); - if (!state->frame) +#if PY_VERSION_HEX < 0x030a0000 + PyFrameObject* frame = state->frame; +#else + PyFrameObject* frame = PyThreadState_GetFrame(state); +#endif + if (!frame) return QVariant(); const char* varName = name.toUtf8().constData(); PyObject* obj = nullptr; - PyFrame_FastToLocals(state->frame); - PyObject* locals = state->frame->f_locals; - PyObject* globals = state->frame->f_globals; + PyFrame_FastToLocals(frame); +#if PY_VERSION_HEX < 0x030b0000 + PyObject* locals = frame->f_locals; + PyObject* globals = frame->f_globals; +#else + PyObject* locals = PyFrame_GetLocals(frame); + PyObject* globals = PyFrame_GetGlobals(frame); +#endif if (PyMapping_Check(locals)) obj = PyMapping_GetItemString(locals, varName); else if (PyDict_Check(globals)) |
