diff options
| -rw-r--r-- | sources/pyside6/libpyside/dynamicslot.cpp | 3 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/pyside.cpp | 5 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/pysidesignal.cpp | 5 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/pysideutils.h | 2 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/qobjectconnect.cpp | 3 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/bindingmanager.cpp | 4 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/helper.cpp | 8 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/helper.h | 3 |
8 files changed, 23 insertions, 10 deletions
diff --git a/sources/pyside6/libpyside/dynamicslot.cpp b/sources/pyside6/libpyside/dynamicslot.cpp index 1fbdba1ab..e0a24558b 100644 --- a/sources/pyside6/libpyside/dynamicslot.cpp +++ b/sources/pyside6/libpyside/dynamicslot.cpp @@ -8,6 +8,7 @@ #include "signalmanager.h" #include <autodecref.h> +#include <helper.h> #include <gilstate.h> #include <pep384ext.h> @@ -26,7 +27,7 @@ DynamicSlot::SlotType DynamicSlot::slotType(PyObject *callback) { if (PyMethod_Check(callback) != 0) return SlotType::Method; - if (PySide::isCompiledMethod(callback) != 0) + if (Shiboken::isCompiledMethod(callback)) return SlotType::CompiledMethod; if (PyCFunction_Check(callback) != 0) return SlotType::C_Function; diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index e061f16a9..c9c9b293f 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -28,6 +28,7 @@ #include <basewrapper.h> #include <bindingmanager.h> #include <gilstate.h> +#include <helper.h> #include <sbkconverter.h> #include <sbkstring.h> #include <sbkstaticstrings.h> @@ -875,9 +876,7 @@ QString pyPathToQString(PyObject *path) bool isCompiledMethod(PyObject *callback) { - return PyObject_HasAttr(callback, PySide::PySideName::im_func()) - && PyObject_HasAttr(callback, PySide::PySideName::im_self()) - && PyObject_HasAttr(callback, PySide::PySideMagicName::code()); + return Shiboken::isCompiledMethod(callback); } static const unsigned char qt_resource_name[] = { diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index 32f00877b..6e5fccae5 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -11,6 +11,7 @@ #include "signalmanager.h" #include <shiboken.h> +#include <helper.h> #include <sbkstaticstrings.h> #include <QtCore/QByteArray> @@ -423,7 +424,7 @@ static FunctionArgumentsResult extractFunctionArgumentsFromSlot(PyObject *slot) ret.objCode = reinterpret_cast<PepCodeObject *>(PyFunction_GET_CODE(ret.function)); ret.functionName = PepFunction_GetName(ret.function); - } else if (PySide::isCompiledMethod(slot)) { + } else if (Shiboken::isCompiledMethod(slot)) { // PYSIDE-1523: PyFunction_Check and PyMethod_Check are not accepting compiled forms, we // just go by attributes. ret.isMethod = true; @@ -1363,7 +1364,7 @@ QByteArray codeCallbackName(PyObject *callback, const QByteArray &funcName) return funcName + QByteArray::number(quint64(self), 16) + QByteArray::number(quint64(func), 16); } // PYSIDE-1523: Handle the compiled case. - if (PySide::isCompiledMethod(callback)) { + if (Shiboken::isCompiledMethod(callback)) { // Not retaining references inline with what PyMethod_GET_(SELF|FUNC) does. Shiboken::AutoDecRef self(PyObject_GetAttr(callback, PySide::PySideName::im_self())); Shiboken::AutoDecRef func(PyObject_GetAttr(callback, PySide::PySideName::im_func())); diff --git a/sources/pyside6/libpyside/pysideutils.h b/sources/pyside6/libpyside/pysideutils.h index 47c2f2c1b..579e7f74c 100644 --- a/sources/pyside6/libpyside/pysideutils.h +++ b/sources/pyside6/libpyside/pysideutils.h @@ -35,6 +35,8 @@ PYSIDE_API QString pyStringToQString(PyObject *str); /// Provide an efficient, correct PathLike interface. PYSIDE_API QString pyPathToQString(PyObject *path); +/// Returns whether \a method is a compiled method (Nuitka). +/// \sa Shiboken::isCompiledMethod() PYSIDE_API bool isCompiledMethod(PyObject *callback); struct debugPyTypeObject diff --git a/sources/pyside6/libpyside/qobjectconnect.cpp b/sources/pyside6/libpyside/qobjectconnect.cpp index 568e248dd..bb98682c2 100644 --- a/sources/pyside6/libpyside/qobjectconnect.cpp +++ b/sources/pyside6/libpyside/qobjectconnect.cpp @@ -13,6 +13,7 @@ #include <sbkstaticstrings.h> #include "basewrapper.h" #include "autodecref.h" +#include <helper.h> #include <QtCore/QDebug> #include <QtCore/QMetaMethod> @@ -113,7 +114,7 @@ static GetReceiverResult getReceiver(QMetaMethod signal, PyObject *callback) } else if (PyCFunction_Check(callback)) { result.self = PyCFunction_GetSelf(callback); result.receiver = PySide::convertToQObject(result.self, false); - } else if (PySide::isCompiledMethod(callback)) { + } else if (Shiboken::isCompiledMethod(callback)) { result.self = PyObject_GetAttr(callback, Shiboken::PyName::im_self()); Py_DECREF(result.self); result.receiver = PySide::convertToQObject(result.self, false); diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp index f75c50c22..810592235 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.cpp +++ b/sources/shiboken6/libshiboken/bindingmanager.cpp @@ -415,9 +415,7 @@ PyObject *BindingManager::getOverride(const void *cptr, Py_DECREF(method); method = nullptr; } - } else if (PyObject_HasAttr(method, PyName::im_self()) - && PyObject_HasAttr(method, PyName::im_func()) - && PyObject_HasAttr(method, Shiboken::PyMagicName::code())) { + } else if (isCompiledMethod(method)) { PyObject *im_self = PyObject_GetAttr(method, PyName::im_self()); // Not retaining a reference inline with what PyMethod_GET_SELF does. Py_DECREF(im_self); diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp index 2a22cdcf2..ab388812e 100644 --- a/sources/shiboken6/libshiboken/helper.cpp +++ b/sources/shiboken6/libshiboken/helper.cpp @@ -621,6 +621,14 @@ const char *typeNameOf(const char *typeIdName) return result; } +bool isCompiledMethod(PyObject *method) +{ + return method != nullptr && method != Py_None + && PyObject_HasAttr(method, PyName::im_self()) != 0 + && PyObject_HasAttr(method, PyName::im_func()) != 0 + && PyObject_HasAttr(method, Shiboken::PyMagicName::code()) != 0; +} + #if !defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030A0000 && !defined(PYPY_VERSION) static int _getPyVerbose() { diff --git a/sources/shiboken6/libshiboken/helper.h b/sources/shiboken6/libshiboken/helper.h index 2ec0e702f..63f76cb52 100644 --- a/sources/shiboken6/libshiboken/helper.h +++ b/sources/shiboken6/libshiboken/helper.h @@ -43,6 +43,9 @@ LIBSHIBOKEN_API int *sequenceToIntArray(PyObject *obj, bool zeroTerminated = fal /// \returns Fixed name (allocated). LIBSHIBOKEN_API const char *typeNameOf(const char *typeIdName); +/// Returns whether \a method is a compiled method (Nuitka). +LIBSHIBOKEN_API bool isCompiledMethod(PyObject *method); + /** * Creates and automatically deallocates C++ arrays. */ |
