aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <[email protected]>2021-11-09 15:24:30 +0100
committerChristian Tismer <[email protected]>2021-11-09 16:12:27 +0100
commit132d425a105749455e174563ec6b7123961c5076 (patch)
tree90c581ce15113e946f46516c8d37f6dd99861589 /sources
parent1c16cad157eb6233c8d128567719d214c395b10e (diff)
PyPySide: Fix BindingManager::getOverride and others
PyPy has a major difference when it comes to distinguish PyCFunction and PyFunction/PyMethod. PyCFunction is not differentiated in PyPy and its handling collapses with PyMethod handling. A simple way to emulate the difference is by a redefinition that uses a check for __module__, that does not exist for builtins. Observation: There are quite a number of false callbacks in Qt that create wrong notifications. Before this error was fixed, these errors were reported by the error handler. When handled correctly, these spurious notifications are ignored, again. The effect of this change is very good: 76 errors left instead of 99. [ChangeLog][shiboken6] The override handling for PyPy was fixed because PyPy has a different understanding of builtin functions. Task-number: PYSIDE-535 Change-Id: I7d7419135a50df9a540e953b75890ca2ec28993c Reviewed-by: Friedemann Kleint <[email protected]>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside6/tests/QtWidgets/paint_event_test.py10
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp1
-rw-r--r--sources/shiboken6/libshiboken/pep384impl.cpp12
-rw-r--r--sources/shiboken6/libshiboken/pep384impl.h9
4 files changed, 22 insertions, 10 deletions
diff --git a/sources/pyside6/tests/QtWidgets/paint_event_test.py b/sources/pyside6/tests/QtWidgets/paint_event_test.py
index 6bfeade6f..96f38f3f2 100644
--- a/sources/pyside6/tests/QtWidgets/paint_event_test.py
+++ b/sources/pyside6/tests/QtWidgets/paint_event_test.py
@@ -99,16 +99,6 @@ class PaintEventOverride(UsesQApplication):
# Test QWidget.paintEvent override
timer_id = self.widget.startTimer(100)
self.widget.show()
- if hasattr(sys, "pypy_version_info"):
- # PYSIDE-535: Next line gives millions of
- orig_exc = dedent("""
- TypeError: 'PySide6.QtWidgets.QApplication.notify' called with wrong argument types:
- PySide6.QtWidgets.QApplication.notify(MyWidget, QPainter)
- Supported signatures:
- PySide6.QtWidgets.QApplication.notify(PySide6.QtCore.QObject, PySide6.QtCore.QEvent)
- """)
- raise SystemError(orig_exc)
-
self.app.exec()
self.widget.killTimer(timer_id)
self.assertTrue(self.widget.paint_event_called)
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 20b331bde..676017a80 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -318,6 +318,7 @@ PyObject *BindingManager::getOverride(const void *cptr,
// PYSIDE-1523: PyMethod_Check is not accepting compiled methods, we do this rather
// crude check for them.
if (method) {
+ // PYSIDE-535: This macro is redefined in a compatible way in pep384
if (PyMethod_Check(method)) {
if (PyMethod_GET_SELF(method) == reinterpret_cast<PyObject *>(wrapper)) {
function = PyMethod_GET_FUNCTION(method);
diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp
index fd862b7b0..ae1a3bcd9 100644
--- a/sources/shiboken6/libshiboken/pep384impl.cpp
+++ b/sources/shiboken6/libshiboken/pep384impl.cpp
@@ -637,6 +637,18 @@ PyMethod_Self(PyObject *im)
}
#endif // Py_LIMITED_API
+#ifdef PYPY_VERSION
+
+// PYSIDE-535: PyPy does not differentiate builtin methods and methods.
+// But they differ because they have no __module__ attribute.
+int PyMethod_Check(PyObject *op)
+{
+ return PyPyMethod_Check(op) &&
+ PyObject_HasAttr(op, Shiboken::PyMagicName::module());
+}
+
+#endif
+
/*****************************************************************************
*
* Support for funcobject.h
diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h
index 134199788..32d8d6fa5 100644
--- a/sources/shiboken6/libshiboken/pep384impl.h
+++ b/sources/shiboken6/libshiboken/pep384impl.h
@@ -415,6 +415,15 @@ LIBSHIBOKEN_API PyObject *PyMethod_Self(PyObject *);
#define PyMethod_GET_FUNCTION(op) PyMethod_Function(op)
#endif
+#ifdef PYPY_VERSION
+
+// PYSIDE-535: PyPy does not differentiate builtin methods and methods.
+// But they differ because they have no __module__ attribute.
+#undef PyMethod_Check
+LIBSHIBOKEN_API int PyMethod_Check(PyObject *op);
+
+#endif
+
/*****************************************************************************
*
* RESOLVED: code.h