Skip to content

Commit fe5a352

Browse files
committed
python311 fix
1 parent 44ec954 commit fe5a352

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/PythonQt.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,25 +2375,27 @@ QString PythonQtPrivate::getSignature(PyObject* object)
23752375
// inspect.getargs() can handle anonymous (tuple) arguments, while this code does not.
23762376
// It can be implemented, but it may be rarely needed and not necessary.
23772377
PyCodeObject* code = (PyCodeObject*)func->func_code;
2378-
if (code->co_varnames) {
2378+
auto varnames = PyCode_GetVarnames(code);
2379+
if (varnames) {
23792380
int nargs = code->co_argcount;
2380-
Q_ASSERT(PyTuple_Check(code->co_varnames));
2381+
Q_ASSERT(PyTuple_Check(varnames));
23812382
for (int i=0; i<nargs; i++) {
2382-
PyObject* name = PyTuple_GetItem(code->co_varnames, i);
2383+
PyObject* name = PyTuple_GetItem(varnames, i);
23832384
Q_ASSERT(PyString_Check(name));
23842385
arguments << PyString_AsString(name);
23852386
}
23862387
if (code->co_flags & CO_VARARGS) {
2387-
PyObject* s = PyTuple_GetItem(code->co_varnames, nargs);
2388+
PyObject* s = PyTuple_GetItem(varnames, nargs);
23882389
Q_ASSERT(PyString_Check(s));
23892390
varargs = PyString_AsString(s);
23902391
nargs += 1;
23912392
}
23922393
if (code->co_flags & CO_VARKEYWORDS) {
2393-
PyObject* s = PyTuple_GetItem(code->co_varnames, nargs);
2394+
PyObject* s = PyTuple_GetItem(varnames, nargs);
23942395
Q_ASSERT(PyString_Check(s));
23952396
varkeywords = PyString_AsString(s);
23962397
}
2398+
Py_DECREF(varnames);
23972399
}
23982400

23992401
PyObject* defaultsTuple = func->func_defaults;

src/PythonQtClassWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "structmember.h"
5050
#include "methodobject.h"
5151
#include "compile.h"
52-
#include "eval.h"
52+
// #include "eval.h"
5353
#include <QString>
5454

5555
class PythonQtClassInfo;

src/PythonQtInstanceWrapper.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include "structmember.h"
5252
#include "methodobject.h"
5353
#include "compile.h"
54-
#include "eval.h"
54+
// #include "eval.h"
5555

5656
class PythonQtClassInfo;
5757
class QObject;
@@ -64,7 +64,7 @@ struct PythonQtInstanceWrapper {
6464
PyObject_HEAD
6565

6666
//! the class information, this is set even if the _obj or _wrappedPtr is NULL to support typed NULL pointers
67-
inline PythonQtClassInfo* classInfo()
67+
inline PythonQtClassInfo* classInfo()
6868
{ return ((PythonQtClassWrapper*)Py_TYPE(this))->_classInfo; }
6969

7070
inline PythonQtDynamicClassInfo* dynamicClassInfo()
@@ -133,4 +133,3 @@ int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args
133133
PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self);
134134

135135
#endif
136-

src/PythonQtSignalReceiver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "PythonQtConversion.h"
4646
#include <QMetaObject>
4747
#include <QMetaMethod>
48-
#include "funcobject.h"
48+
// #include "funcobject.h"
4949

5050
// use -2 to signal that the variable is uninitialized
5151
int PythonQtSignalReceiver::_destroyedSignal1Id = -2;
@@ -279,4 +279,3 @@ int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void **argu
279279
}
280280
return 0;
281281
}
282-

0 commit comments

Comments
 (0)