Author: Philip Jenvey <[email protected]>
Branch:
Changeset: r83755:5d26a6aafe9b
Date: 2016-04-18 17:42 -0700
http://bitbucket.org/pypy/pypy/changeset/5d26a6aafe9b/
Log: fix isinstance(deque(), Hashable) on the pure python deque
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -320,8 +320,7 @@
def __reduce_ex__(self, proto):
return type(self), (list(self), self.maxlen)
- def __hash__(self):
- raise TypeError("deque objects are unhashable")
+ __hash__ = None
def __copy__(self):
return self.__class__(self, self.maxlen)
diff --git a/pypy/module/test_lib_pypy/test_collections.py
b/pypy/module/test_lib_pypy/test_collections.py
--- a/pypy/module/test_lib_pypy/test_collections.py
+++ b/pypy/module/test_lib_pypy/test_collections.py
@@ -62,6 +62,12 @@
raises(IndexError, d.remove, 'c')
assert len(d) == 0
+ def test_deque_unhashable(self):
+ from collections import Hashable
+ d = self.get_deque()
+ raises(TypeError, hash, d)
+ assert not isinstance(d, Hashable)
+
class AppTestDequeExtra:
spaceconfig = dict(usemodules=('binascii', 'struct',))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit