Commits

Brian Kearns committed a8d4721

backout accidental inclusion to last commit

Comments (0)

Files changed (1)

lib_pypy/_collections.py

         return c
 
     def remove(self, value):
+        # Need to be defensive for mutating comparisons
         for i in range(len(self)):
-            elem = self.popleft()
-            if elem == value:
-                break
-            self.append(elem)
-        else:
-            raise ValueError("deque.remove(x): x not in deque")
-        for i in range(len(self) - i):
-            self.append(self.popleft())
+            if self[i] == value:
+                del self[i]
+                return
+        raise ValueError("deque.remove(x): x not in deque")
 
     def rotate(self, n=1):
         length = len(self)