Porting Py3.8/Py3.9:

Since Py3.3: 'Py_ssize_t PyUnicode_GetSize(PyObject*)' is deprecated [-Wdeprecated-declarations]
Since Py3.9: 'PyObject* PyEval_CallObjectWithKeywords(PyObject*, PyObject*, PyObject*)' is deprecated [-Wdeprecated-declarations]
Since Py3.9: 'void PyEval_InitThreads()' is deprecated [-Wdeprecated-declarations]
This commit is contained in:
wmayer
2020-06-08 23:17:08 +02:00
committed by wwmayer
parent 97701e3a73
commit 3f212ad8ac
9 changed files with 76 additions and 6 deletions

View File

@@ -419,7 +419,11 @@ void StdCmdPythonHelp::activated(int iMsg)
char szBuf[201];
snprintf(szBuf, 200, "http://localhost:%d", port);
PyObject* args = Py_BuildValue("(s)", szBuf);
#if PY_VERSION_HEX < 0x03090000
PyObject* result = PyEval_CallObject(func,args);
#else
PyObject* result = PyObject_CallObject(func,args);
#endif
if (result)
failed = false;
@@ -455,7 +459,11 @@ bool Gui::OpenURLInBrowser(const char * URL)
PyObject* func = PyDict_GetItemString(dict, "open");
if (func) {
PyObject* args = Py_BuildValue("(s)", URL);
#if PY_VERSION_HEX < 0x03090000
PyObject* result = PyEval_CallObject(func,args);
#else
PyObject* result = PyObject_CallObject(func,args);
#endif
if (result)
failed = false;

View File

@@ -141,7 +141,11 @@ InteractiveInterpreter::InteractiveInterpreter()
PyObject* func = PyObject_GetAttrString(module, "InteractiveInterpreter");
PyObject* args = Py_BuildValue("()");
d = new InteractiveInterpreterP;
#if PY_VERSION_HEX < 0x03090000
d->interpreter = PyEval_CallObject(func,args);
#else
d->interpreter = PyObject_CallObject(func,args);
#endif
Py_DECREF(args);
Py_DECREF(func);
Py_DECREF(module);
@@ -195,7 +199,11 @@ PyObject* InteractiveInterpreter::compile(const char* source) const
Base::PyGILStateLocker lock;
PyObject* func = PyObject_GetAttrString(d->interpreter, "compile");
PyObject* args = Py_BuildValue("(s)", source);
#if PY_VERSION_HEX < 0x03090000
PyObject* eval = PyEval_CallObject(func,args); // must decref later
#else
PyObject* eval = PyObject_CallObject(func,args); // must decref later
#endif
Py_DECREF(args);
Py_DECREF(func);
@@ -227,7 +235,11 @@ int InteractiveInterpreter::compileCommand(const char* source) const
Base::PyGILStateLocker lock;
PyObject* func = PyObject_GetAttrString(d->interpreter, "compile");
PyObject* args = Py_BuildValue("(s)", source);
#if PY_VERSION_HEX < 0x03090000
PyObject* eval = PyEval_CallObject(func,args); // must decref later
#else
PyObject* eval = PyObject_CallObject(func,args); // must decref later
#endif
Py_DECREF(args);
Py_DECREF(func);

View File

@@ -1677,7 +1677,11 @@ void SignalConnect::onExecute()
/* Time to call the callback */
arglist = Py_BuildValue("(O)", myResource);
#if PY_VERSION_HEX < 0x03090000
result = PyEval_CallObject(myCallback, arglist);
#else
result = PyObject_CallObject(myCallback, arglist);
#endif
Py_XDECREF(result);
Py_DECREF(arglist);
}

View File

@@ -850,7 +850,11 @@ void UrlLabel::mouseReleaseEvent (QMouseEvent *)
PyObject* func = PyDict_GetItemString(dict, "open");
if (func) {
PyObject* args = Py_BuildValue("(s)", (const char*)this->_url.toLatin1());
#if PY_VERSION_HEX < 0x03090000
PyObject* result = PyEval_CallObject(func,args);
#else
PyObject* result = PyObject_CallObject(func,args);
#endif
// decrement the args and module reference
Py_XDECREF(result);
Py_DECREF(args);