Return an int for __hash__

This commit is contained in:
Guillaume Ayoub 2013-10-31 14:05:15 +01:00
parent 92b3cf41bc
commit a920518a26
2 changed files with 5 additions and 5 deletions

View File

@ -13,7 +13,7 @@
* Support colors (by Jochen Sprickerhof) * Support colors (by Jochen Sprickerhof)
* Decode URLs in XML (by Jean-Marc Martins) * Decode URLs in XML (by Jean-Marc Martins)
* Fix PAM authentication (by Stepan Henek) * Fix PAM authentication (by Stepan Henek)
* Use consistent hashes for etags (by 9m66p93w) * Use consistent etags (by 9m66p93w)
0.8 - Rainbow 0.8 - Rainbow

View File

@ -110,9 +110,7 @@ class Item(object):
"\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name) "\nEND:", "\nX-RADICALE-NAME:%s\nEND:" % self._name)
def __hash__(self): def __hash__(self):
md5 = hashlib.md5() return hash(self.text)
md5.update(self.text.encode("utf-8"))
return md5.hexdigest()
def __eq__(self, item): def __eq__(self, item):
return isinstance(item, Item) and self.text == item.text return isinstance(item, Item) and self.text == item.text
@ -124,7 +122,9 @@ class Item(object):
Etag is mainly used to know if an item has changed. Etag is mainly used to know if an item has changed.
""" """
return '"%s"' % hash(self) md5 = hashlib.md5()
md5.update(self.text.encode("utf-8"))
return '"%s"' % md5.hexdigest()
@property @property
def name(self): def name(self):