Author: Richard Plangger <planri...@gmail.com> Branch: py3.5 Changeset: r87836:e5f49cf46985 Date: 2016-10-17 14:19 +0200 http://bitbucket.org/pypy/pypy/changeset/e5f49cf46985/
Log: add check lock to impl of deque.index 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 @@ -334,6 +334,7 @@ _len = self.len start = 0 stop = _len + lock = self.getlock() if w_start is not None: start = space.int_w(w_start) @@ -358,6 +359,7 @@ continue if space.eq_w(w_obj, w_x): return space.wrap(i) + self.checklock(lock) except OperationError as e: if not e.match(space, space.w_StopIteration): raise 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 @@ -362,3 +362,21 @@ d = deque(range(10)) d.insert(-1, 500) assert d.index(500) == 9 + + def test_deque_raises_runtimeerror(self): + from _collections import deque + n = 200 + class MutateCmp: + def __init__(self, deque, result): + self.deque = deque + self.result = result + def __eq__(self, other): + self.deque.clear() + return self.result + d = deque(range(n)) + d[n//2] = MutateCmp(d, False) + try: + d.index(n) + assert 0, "must raise!" + except RuntimeError: + pass _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit