Skip to content

Python 3.10 compatibility #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/PythonQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

#include <QDir>

#include <pydebug.h>
#include <vector>

PythonQt* PythonQt::_self = NULL;
Expand Down Expand Up @@ -2423,22 +2422,27 @@ 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) {
#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(code->co_varnames));
Q_ASSERT(PyTuple_Check(co_varnames));
for (int i=0; i<nargs; i++) {
PyObject* name = PyTuple_GetItem(code->co_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);
}
Expand Down
1 change: 0 additions & 1 deletion src/PythonQtClassWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "structmember.h"
#include "methodobject.h"
#include "compile.h"
#include "eval.h"
#include <QString>

class PythonQtClassInfo;
Expand Down
1 change: 0 additions & 1 deletion src/PythonQtInstanceWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "structmember.h"
#include "methodobject.h"
#include "compile.h"
#include "eval.h"

class PythonQtClassInfo;
class QObject;
Expand Down
1 change: 0 additions & 1 deletion src/PythonQtSignalReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "PythonQtConversion.h"
#include <QMetaObject>
#include <QMetaMethod>
#include "funcobject.h"

// use -2 to signal that the variable is uninitialized
int PythonQtSignalReceiver::_destroyedSignal1Id = -2;
Expand Down