Fix __hash__ in functools.cmp_to_key() to work with collections.Hashable.

This commit is contained in:
Raymond Hettinger 2011-05-03 11:16:36 -07:00
commit e7a2430dde
3 changed files with 6 additions and 3 deletions

View file

@ -111,8 +111,7 @@ def cmp_to_key(mycmp):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
def __hash__(self):
raise TypeError('hash not implemented')
__hash__ = None
return K
try: