changeset 608:c4c1544e9b7b

Make GF256 hashable in Python 2.6. Python 2.5 has a default fallback where id(x) was used if x had not __hash__ method, but in Python 2.6 one gets the error exceptions.TypeError: unhashable type: 'GF256' instead. Defining a suitable __hash__ method solves this.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 25 Mar 2008 21:36:45 +0100
parents 626cd75d75fb
children 2e6a8de5f13c
files viff/field.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/field.py	Tue Mar 25 19:18:11 2008 +0100
+++ b/viff/field.py	Tue Mar 25 21:36:45 2008 +0100
@@ -263,6 +263,10 @@
             other = other.value
         return self.value == other
 
+    def __hash__(self):
+        """Hash value."""
+        return hash((self.field, self.value))
+
     def __nonzero__(self):
         """Truth value testing.