aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libshiboken/sbkenum.cpp48
-rw-r--r--tests/samplebinding/enum_test.py6
2 files changed, 28 insertions, 26 deletions
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index c372f0b7..e65cbd7a 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -192,32 +192,28 @@ static PyObject* enum_richcompare(PyObject* self, PyObject* other, int op)
long valA = SBK_ENUM(self)->ob_value;
long valB = getNumberValue(other);
- if (self == other) {
- result = 1;
- } else {
- switch (op) {
- case Py_EQ:
- result = (valA == valB);
- break;
- case Py_NE:
- result = (valA != valB);
- break;
- case Py_LE:
- result = (valA <= valB);
- break;
- case Py_GE:
- result = (valA >= valB);
- break;
- case Py_LT:
- result = (valA < valB);
- break;
- case Py_GT:
- result = (valA > valB);
- break;
- default:
- PyErr_BadArgument();
- return NULL;
- }
+ switch (op) {
+ case Py_EQ:
+ result = (valA == valB);
+ break;
+ case Py_NE:
+ result = (valA != valB);
+ break;
+ case Py_LE:
+ result = (valA <= valB);
+ break;
+ case Py_GE:
+ result = (valA >= valB);
+ break;
+ case Py_LT:
+ result = (valA < valB);
+ break;
+ case Py_GT:
+ result = (valA > valB);
+ break;
+ default:
+ PyErr_BadArgument();
+ return NULL;
}
if (result)
Py_RETURN_TRUE;
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py
index 6b3609a3..8346f39d 100644
--- a/tests/samplebinding/enum_test.py
+++ b/tests/samplebinding/enum_test.py
@@ -141,6 +141,12 @@ class EnumOverloadTest(unittest.TestCase):
self.assertEqual(o.callWithEnum('', Event.ANY_EVENT, 9), 81)
self.assertEqual(o.callWithEnum('', 9), 9)
+class EnumOperators(unittest.TestCase):
+ '''Test case for operations on enums'''
+
+ def testInequalitySameObject(self):
+ self.assertFalse(Event.ANY_EVENT != Event.ANY_EVENT)
+
if __name__ == '__main__':
unittest.main()