diff options
author | Alex Hughes <ahughesalex@gmail.com> | 2018-04-08 13:45:41 -0700 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-09-08 17:57:33 +0200 |
commit | c7904338f8707a30c70f1ddf62ec740cae255f36 (patch) | |
tree | a3c6bffb2fdeffc6885bd34a324ae391dbb205e4 /sources/shiboken2/libshiboken/basewrapper.h | |
parent | c5d47637c7376358a10f0f845e443478058a5430 (diff) |
Implement default __ne__ and __eq__ for all PySide types
PySide types have been following the Qt implementation of
comparisons, completely.
This is not correct for Python, because the Python default has
the operators `==` and `!=` at least. They are needed for tests
like `obj in collection`.
We fix this by redirecting the default case to
`PyBaseObject_Type.tp_richcompare`.
This is the correct way to fix it, because for types which do not
define `tp_richcompare', this is the default, anyway.
From the original patch, the test case is still in use.
Old message:
Implement __ne__ and __eq__ for QTreeWidgetItem
Testing if a QTreeWidgetItem belongs to a list raises a NotImplementedError.
I have exposed the operator== and the operator!= from C++ to shiboken which has solved our eq operator issue.
Implemented the test from PYSIDE-74 for the QTreeWidgetItem eq operator and the ne operator.
This also allows us to have the behavior "QTreeWidgetItem in ['a']" and "QTreeWidgetItem not in ['a']".
Adding qtreewidgetitem_test.py to CMakeFiles.txt
Fixes: PYSIDE-74
Change-Id: Id221c0163fc8c2d85730c4c26f22db5f61710706
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper.h')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.h b/sources/shiboken2/libshiboken/basewrapper.h index b233c02b4..267759daa 100644 --- a/sources/shiboken2/libshiboken/basewrapper.h +++ b/sources/shiboken2/libshiboken/basewrapper.h @@ -135,6 +135,9 @@ LIBSHIBOKEN_API PyObject *SbkDummyNew(PyTypeObject *type, PyObject *, PyObject * LIBSHIBOKEN_API PyObject *SbkType_FromSpec(PyType_Spec *); LIBSHIBOKEN_API PyObject *SbkType_FromSpecWithBases(PyType_Spec *, PyObject *); +/// PYSIDE-74: Fallback used in all types now. +LIBSHIBOKEN_API PyObject *FallbackRichCompare(PyObject *self, PyObject *other, int op); + } // extern "C" namespace Shiboken |