viff

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 diff
     1.1 --- a/viff/field.py	Tue Mar 25 19:18:11 2008 +0100
     1.2 +++ b/viff/field.py	Tue Mar 25 21:36:45 2008 +0100
     1.3 @@ -263,6 +263,10 @@
     1.4              other = other.value
     1.5          return self.value == other
     1.6  
     1.7 +    def __hash__(self):
     1.8 +        """Hash value."""
     1.9 +        return hash((self.field, self.value))
    1.10 +
    1.11      def __nonzero__(self):
    1.12          """Truth value testing.
    1.13