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

This commit is contained in:
Raymond Hettinger 2011-05-03 11:01:32 -07:00
parent 5098d44354
commit 003be52932
3 changed files with 7 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
_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")