From dd025a69a5b08d81149894e5fbb2ce45e096a8b8 Mon Sep 17 00:00:00 2001 From: Stefan Dinkelacker Date: Mon, 8 Aug 2022 10:13:56 +0200 Subject: [PATCH 1/3] Remove unused header include The location of pydebug.h changed in Python 3.10 but it is not used anyway. --- src/PythonQt.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index 3b33cdec..4fd863f0 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -58,7 +58,6 @@ #include -#include #include PythonQt* PythonQt::_self = NULL; From dd8c83b82472573e426fc8d6fa1ea6e1cf7331f5 Mon Sep 17 00:00:00 2001 From: Stefan Dinkelacker Date: Wed, 13 Dec 2023 17:26:04 +0100 Subject: [PATCH 2/3] Make PythonQt build with Python 3.11 --- src/PythonQt.cpp | 11 ++++++----- src/PythonQtClassWrapper.h | 1 - src/PythonQtInstanceWrapper.h | 1 - src/PythonQtSignalReceiver.cpp | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index 4fd863f0..512ec9a9 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -2422,22 +2422,23 @@ QString PythonQtPrivate::getSignature(PyObject* object) // inspect.getargs() can handle anonymous (tuple) arguments, while this code does not. // It can be implemented, but it may be rarely needed and not necessary. PyCodeObject* code = (PyCodeObject*)func->func_code; - if (code->co_varnames) { + PyObject* co_varnames = PyCode_GetVarnames(code); + if (co_varnames) { int nargs = code->co_argcount; - Q_ASSERT(PyTuple_Check(code->co_varnames)); + Q_ASSERT(PyTuple_Check(co_varnames)); for (int i=0; ico_varnames, i); + PyObject* name = PyTuple_GetItem(co_varnames, i); Q_ASSERT(PyString_Check(name)); arguments << PyString_AsString(name); } if (code->co_flags & CO_VARARGS) { - PyObject* s = PyTuple_GetItem(code->co_varnames, nargs); + PyObject* s = PyTuple_GetItem(co_varnames, nargs); Q_ASSERT(PyString_Check(s)); varargs = PyString_AsString(s); nargs += 1; } if (code->co_flags & CO_VARKEYWORDS) { - PyObject* s = PyTuple_GetItem(code->co_varnames, nargs); + PyObject* s = PyTuple_GetItem(co_varnames, nargs); Q_ASSERT(PyString_Check(s)); varkeywords = PyString_AsString(s); } diff --git a/src/PythonQtClassWrapper.h b/src/PythonQtClassWrapper.h index e136e3d4..53c1d3ca 100644 --- a/src/PythonQtClassWrapper.h +++ b/src/PythonQtClassWrapper.h @@ -49,7 +49,6 @@ #include "structmember.h" #include "methodobject.h" #include "compile.h" -#include "eval.h" #include class PythonQtClassInfo; diff --git a/src/PythonQtInstanceWrapper.h b/src/PythonQtInstanceWrapper.h index 8c04d03e..26ac6a0e 100644 --- a/src/PythonQtInstanceWrapper.h +++ b/src/PythonQtInstanceWrapper.h @@ -51,7 +51,6 @@ #include "structmember.h" #include "methodobject.h" #include "compile.h" -#include "eval.h" class PythonQtClassInfo; class QObject; diff --git a/src/PythonQtSignalReceiver.cpp b/src/PythonQtSignalReceiver.cpp index 734ec017..b68988be 100644 --- a/src/PythonQtSignalReceiver.cpp +++ b/src/PythonQtSignalReceiver.cpp @@ -45,7 +45,6 @@ #include "PythonQtConversion.h" #include #include -#include "funcobject.h" // use -2 to signal that the variable is uninitialized int PythonQtSignalReceiver::_destroyedSignal1Id = -2; From 1a76f566933217178ea3c3a808d7a9ff62a519b4 Mon Sep 17 00:00:00 2001 From: Stefan Dinkelacker Date: Sun, 17 Dec 2023 09:19:56 +0100 Subject: [PATCH 3/3] Make PythonQt compile with Python v3.9 - v3.12 --- src/PythonQt.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index 512ec9a9..ca98c3c7 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -2422,7 +2422,11 @@ QString PythonQtPrivate::getSignature(PyObject* object) // inspect.getargs() can handle anonymous (tuple) arguments, while this code does not. // It can be implemented, but it may be rarely needed and not necessary. PyCodeObject* code = (PyCodeObject*)func->func_code; +#if PY_VERSION_HEX < (3 << 24 | 11 << 16) + PyObject* co_varnames = code->co_varnames; +#else PyObject* co_varnames = PyCode_GetVarnames(code); +#endif if (co_varnames) { int nargs = code->co_argcount; Q_ASSERT(PyTuple_Check(co_varnames));