Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88498:83ba4f51767c
Date: 2016-11-20 17:39 +0100
http://bitbucket.org/pypy/pypy/changeset/83ba4f51767c/

Log:    Deque addition specifically checks that the argument is another
        deque.

diff --git a/pypy/module/_collections/interp_deque.py 
b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -178,11 +178,12 @@
                 raise
             self.append(w_obj)
 
-    def add(self, w_iterable):
+    def add(self, w_deque):
+        deque = self.space.interp_w(W_Deque, w_deque)
         copy = W_Deque(self.space)
         copy.maxlen = self.maxlen
         copy.extend(self.iter())
-        copy.extend(w_iterable)
+        copy.extend(deque.iter())
         return self.space.wrap(copy)
 
     def iadd(self, w_iterable):
diff --git a/pypy/module/_collections/test/test_deque.py 
b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -122,6 +122,10 @@
         d2 = deque([3,4,5])
         assert d1 + d2 == deque([1,2,3,3,4,5])
 
+    def test_cannot_add_list(self):
+        from _collections import deque
+        raises(TypeError, "deque([2]) + [3]")
+
     def test_iadd(self):
         from _collections import deque
         d = deque('a')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to