Author: Reuben Cummings <[email protected]>
Branch: py3.5
Changeset: r87660:a9547a8c7444
Date: 2016-10-09 13:14 +0300
http://bitbucket.org/pypy/pypy/changeset/a9547a8c7444/

Log:    Fix deque mul and implement imul (reubano & plan_rich)

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
@@ -185,17 +185,26 @@
         return self.space.wrap(self)
 
     def mul(self, w_int):
-        copied = self.copy()
-        num = self.space.int_w(w_int)
+        space = self.space
+        copied = W_Deque(space)
+        num = space.int_w(w_int)
 
         for _ in range(num):
-            copied.extend(copied)
+            copied.extend(self)
 
-        return self.space.wrap(copied)
+        return space.wrap(copied)
 
 
-    def imul(self, w_iterable):
-        pass
+    def imul(self, w_int):
+        space = self.space
+        copied = self.copy()
+        num = space.int_w(w_int)
+
+        for _ in range(num - 1):
+            self.extend(copied)
+
+        return space.wrap(self)
+
 
     def copy(self):
         """ A shallow copy """
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to