diff options
author | Christian Tismer <tismer@stackless.com> | 2020-09-03 11:49:22 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-09-04 10:42:01 +0200 |
commit | 2bd69b9877f7b240512f03b4df042adf9acea744 (patch) | |
tree | cb5667739064968de6b2a723da2195cccbb9d277 /sources/pyside2/libpyside/pysideslot.cpp | |
parent | d02b070e23c757fa72a66a4049a659f4f5c5fc77 (diff) |
Add compatibility with Nuitka
This patch is based upon the old PYSIDE-198 proposal.
It worked with a few changes on Python 3 with limited API disabled.
When enabling the Limited API, there were a lot of crashes. This was
due to the way we need to get around access to certain implementations.
This showed that the original patch was wrong in the expression of
bindingmanager.cpp
bool isCompiled = !isMethod && Py_TYPE(method)->tp_call != nullptr;
After fixing this expression with
bool isCompiled = !isMethod && Py_TYPE(method) != &PyCFunction_Type
&& Py_TYPE(method)->tp_call != nullptr;
everything worked fine with the Limited API, too.
Fixes: PYSIDE-198
Task-number: PYSIDE-829
Change-Id: I4f887c639628041682052e90ba4c72aa98284e9e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside2/libpyside/pysideslot.cpp')
-rw-r--r-- | sources/pyside2/libpyside/pysideslot.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
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); |