Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
- --- a/lib_pypy/_collections.py
- +++ b/lib_pypy/_collections.py
- @@ -142,12 +142,18 @@
- return c
- def remove(self, value):
- - # Need to be defensive for mutating comparisons
- - for i in range(len(self)):
- - if self[i] == value:
- - del self[i]
- - return
- - raise ValueError("deque.remove(x): x not in deque")
- + # Need to defend against mutating or failing comparisons
- + i = 0
- + try:
- + for i in range(len(self)):
- + if self[0] == value:
- + self.popleft()
- + return
- + self.append(self.popleft())
- + i += 1
- + raise ValueError("deque.remove(x): x not in deque")
- + finally:
- + self.rotate(i)
- def rotate(self, n=1):
- length = len(self)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement