aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-10-28 15:22:20 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:18:24 -0300
commit2a5330b26469914db917c019b97b5966e4f26014 (patch)
tree2e21fcf757cb3efbbc552fe5cc5839eca1ba82ec
parent05aae9a59e9dbc8eec6eb33f86df8de4de71cc67 (diff)
Fix bug 1033 - "QDialog.DialogCode instances and return value from QDialog.exec_ hash to different values"
-rw-r--r--libshiboken/sbkenum.cpp5
-rw-r--r--tests/samplebinding/enum_test.py4
2 files changed, 6 insertions, 3 deletions
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index e65cbd7a6..554618db6 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -223,7 +223,10 @@ static PyObject* enum_richcompare(PyObject* self, PyObject* other, int op)
static Py_hash_t enum_hash(PyObject* pyObj)
{
- return PyObject_Hash(reinterpret_cast<SbkEnumObject*>(pyObj)->ob_name);
+ Py_hash_t val = reinterpret_cast<SbkEnumObject*>(pyObj)->ob_value;
+ if (val == -1)
+ val = -2;
+ return val;
}
static PyGetSetDef SbkEnumGetSetList[] = {
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py
index 8346f39d7..7d95f669c 100644
--- a/tests/samplebinding/enum_test.py
+++ b/tests/samplebinding/enum_test.py
@@ -52,8 +52,8 @@ class EnumTest(unittest.TestCase):
self.assertEqual(eval(repr(enum)), enum)
def testHashability(self):
- '''Enums should be hashable and different enums with different values should have different hashes'''
- self.assertNotEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.TwoOut))
+ self.assertEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.TwoOut))
+ self.assertNotEqual(hash(SampleNamespace.TwoIn), hash(SampleNamespace.OneIn))
def testEnumValuesInsideEnum(self):
'''Enum values should be accessible inside the enum as well as outside.'''