diff options
author | David Bolen <db3l.net@gmail.com> | 2012-03-07 11:13:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-03-12 13:48:14 +0000 |
commit | 82bf2998cb243f3269e39de8daee56cb6bc04550 (patch) | |
tree | e4d108d111088679f84a533fa1ec4986e9517d9b /pyuno | |
parent | ede11e29bf051e3d78503333b45118cd011d582a (diff) |
fdo#46926: fix UNO struct comparison in Python 2
This requires setting a rich comparison flag in Python 2, while Python 3
uses rich comparison by default.
(regression from a09ce46818fd4d5e08b3af9a478501cd8ef5b4fe)
(cherry picked from commit 387389b644b91808fdee74846b2d855382f48ed7)
Signed-off-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'pyuno')
-rw-r--r-- | pyuno/source/module/pyuno.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index 2bfbe7b64002..82e29ac8aa4e 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -641,9 +641,16 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op ) { raisePyExceptionWithAny( makeAny( e ) ); } - return Py_False; + return (op == Py_EQ ? Py_False : Py_True); } +/* Python 2 has a tp_flags value for rich comparisons. Python 3 does not (on by default) */ +#ifdef Py_TPFLAGS_HAVE_RICHCOMPARE +#define TP_FLAGS (Py_TPFLAGS_HAVE_RICHCOMPARE) +#else +#define TP_FLAGS 0 +#endif + static PyTypeObject PyUNOType = { PyVarObject_HEAD_INIT( &PyType_Type, 0 ) @@ -654,7 +661,7 @@ static PyTypeObject PyUNOType = (printfunc) 0, (getattrfunc) PyUNO_getattr, (setattrfunc) PyUNO_setattr, - 0, + (cmpfunc) 0, (reprfunc) PyUNO_repr, 0, 0, @@ -665,7 +672,7 @@ static PyTypeObject PyUNOType = (getattrofunc)0, (setattrofunc)0, NULL, - 0, + TP_FLAGS, NULL, (traverseproc)0, (inquiry)0, |