aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject.cpp3
-rw-r--r--sources/pyside2/libpyside/pysideslot.cpp16
-rw-r--r--sources/shiboken2/libshiboken/bindingmanager.cpp14
-rw-r--r--sources/shiboken2/libshiboken/sbkstaticstrings.cpp2
-rw-r--r--sources/shiboken2/libshiboken/sbkstaticstrings.h1
-rw-r--r--sources/shiboken2/libshiboken/sbkstaticstrings_p.h1
6 files changed, 24 insertions, 13 deletions
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject.cpp b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
index efdf33ac9..2fbda3f6a 100644
--- a/sources/pyside2/libpyside/dynamicqmetaobject.cpp
+++ b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
@@ -533,7 +533,8 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
const int index = m_baseObject->indexOfProperty(String::toCString(key));
if (index == -1)
addProperty(String::toCString(key), value);
- } else if (PyFunction_Check(value)) {
+ } else if (Py_TYPE(value)->tp_call != nullptr) {
+ // PYSIDE-198: PyFunction_Check does not work with Nuitka.
// Register slots.
if (PyObject_HasAttr(value, slotAttrName)) {
PyObject *signatureList = PyObject_GetAttr(value, slotAttrName);
diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp
index e60115450..7bfd1719a 100644
--- a/sources/pyside2/libpyside/pysideslot.cpp
+++ b/sources/pyside2/libpyside/pysideslot.cpp
@@ -47,6 +47,8 @@
#include <QtCore/QString>
#include <signature.h>
+using namespace Shiboken;
+
struct SlotData
{
QByteArray name;
@@ -136,23 +138,25 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
callback = PyTuple_GetItem(args, 0);
Py_INCREF(callback);
- if (PyFunction_Check(callback)) {
+ if (Py_TYPE(callback)->tp_call != nullptr) {
PySideSlot *data = reinterpret_cast<PySideSlot *>(self);
if (!data->slotData)
data->slotData = new SlotData;
- if (data->slotData->name.isEmpty())
- data->slotData->name = Shiboken::String::toCString(PepFunction_GetName(callback));
-
+ if (data->slotData->name.isEmpty()) {
+ // PYSIDE-198: Use PyObject_GetAttr instead of PepFunction_GetName to support Nuitka.
+ AutoDecRef funcName(PyObject_GetAttr(callback, PyMagicName::name()));
+ data->slotData->name = String::toCString(funcName);
+ }
const QByteArray returnType = QMetaObject::normalizedType(data->slotData->resultType);
const QByteArray signature =
returnType + ' ' + data->slotData->name + '(' + data->slotData->args + ')';
if (!pySlotName)
- pySlotName = Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR);
+ pySlotName = String::fromCString(PYSIDE_SLOT_LIST_ATTR);
- PyObject *pySignature = Shiboken::String::fromCString(signature);
+ PyObject *pySignature = String::fromCString(signature);
PyObject *signatureList = 0;
if (PyObject_HasAttr(callback, pySlotName)) {
signatureList = PyObject_GetAttr(callback, pySlotName);
diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp
index 4f8c6068a..7b06a4a00 100644
--- a/sources/shiboken2/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken2/libshiboken/bindingmanager.cpp
@@ -305,15 +305,21 @@ PyObject *BindingManager::getOverride(const void *cptr, PyObject *methodNameCach
PyObject *method = PyObject_GetAttr(reinterpret_cast<PyObject *>(wrapper), pyMethodName);
- if (method && PyMethod_Check(method)
- && PyMethod_GET_SELF(method) == reinterpret_cast<PyObject *>(wrapper)) {
+ // PYSIDE-198: Support for Nuitka compiled methods.
+ bool isMethod = method && PyMethod_Check(method);
+ bool isCompiled = !( isMethod
+ || Py_TYPE(method) == &PyCFunction_Type
+ || Py_TYPE(method)->tp_call == nullptr);
+ Shiboken::AutoDecRef meth_self(PyObject_GetAttr(method, Shiboken::PyMagicName::self()));
+ bool wrapsParent = meth_self.object() == reinterpret_cast<PyObject *>(wrapper);
+ if ((isMethod && wrapsParent) || isCompiled) {
PyObject *defaultMethod;
PyObject *mro = Py_TYPE(wrapper)->tp_mro;
// The first class in the mro (index 0) is the class being checked and it should not be tested.
// The last class in the mro (size - 1) is the base Python object class which should not be tested also.
- for (int i = 1; i < PyTuple_GET_SIZE(mro) - 1; i++) {
- auto *parent = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i));
+ for (int idx = 1; idx < PyTuple_GET_SIZE(mro) - 1; ++idx) {
+ auto *parent = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
if (parent->tp_dict) {
defaultMethod = PyDict_GetItem(parent->tp_dict, pyMethodName);
if (defaultMethod && PyMethod_GET_FUNCTION(method) != defaultMethod)
diff --git a/sources/shiboken2/libshiboken/sbkstaticstrings.cpp b/sources/shiboken2/libshiboken/sbkstaticstrings.cpp
index 602c0619b..564853edb 100644
--- a/sources/shiboken2/libshiboken/sbkstaticstrings.cpp
+++ b/sources/shiboken2/libshiboken/sbkstaticstrings.cpp
@@ -86,6 +86,7 @@ STATIC_STRING_IMPL(members, "__members__")
STATIC_STRING_IMPL(module, "__module__")
STATIC_STRING_IMPL(name, "__name__")
STATIC_STRING_IMPL(qualname, "__qualname__")
+STATIC_STRING_IMPL(self, "__self__")
// Internal:
STATIC_STRING_IMPL(base, "__base__")
@@ -99,7 +100,6 @@ STATIC_STRING_IMPL(iter, "__iter__")
STATIC_STRING_IMPL(mro, "__mro__")
STATIC_STRING_IMPL(new_, "__new__")
STATIC_STRING_IMPL(objclass, "__objclass__")
-STATIC_STRING_IMPL(self, "__self__")
STATIC_STRING_IMPL(signature, "__signature__")
STATIC_STRING_IMPL(weakrefoffset, "__weakrefoffset__")
} // namespace PyMagicName
diff --git a/sources/shiboken2/libshiboken/sbkstaticstrings.h b/sources/shiboken2/libshiboken/sbkstaticstrings.h
index df0c683b0..d8744bd8d 100644
--- a/sources/shiboken2/libshiboken/sbkstaticstrings.h
+++ b/sources/shiboken2/libshiboken/sbkstaticstrings.h
@@ -72,6 +72,7 @@ LIBSHIBOKEN_API PyObject *members();
LIBSHIBOKEN_API PyObject *module();
LIBSHIBOKEN_API PyObject *name();
LIBSHIBOKEN_API PyObject *qualname();
+LIBSHIBOKEN_API PyObject *self();
} // namespace PyMagicName
} // namespace Shiboken
diff --git a/sources/shiboken2/libshiboken/sbkstaticstrings_p.h b/sources/shiboken2/libshiboken/sbkstaticstrings_p.h
index 12c11376f..c33fa0299 100644
--- a/sources/shiboken2/libshiboken/sbkstaticstrings_p.h
+++ b/sources/shiboken2/libshiboken/sbkstaticstrings_p.h
@@ -67,7 +67,6 @@ PyObject *module();
PyObject *mro();
PyObject *new_();
PyObject *objclass();
-PyObject *self();
PyObject *signature();
PyObject *weakrefoffset();
} // namespace PyMagicName