[pypy-commit] pypy py3.5: fix pickling reversed(list)
arigo
pypy.commits at gmail.com
Mon Dec 12 09:20:15 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89023:fc7ceff2ed1f
Date: 2016-12-12 15:03 +0100
http://bitbucket.org/pypy/pypy/changeset/fc7ceff2ed1f/
Log: fix pickling reversed(list)
diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -164,7 +164,6 @@
index = space.int_w(w_state)
if self.w_seq is not None:
length = space.int_w(space.len(self.w_seq))
- if index < 0: index = 0
if index >= length: index = length-1
self.index = index
diff --git a/pypy/objspace/std/test/test_iterobject.py b/pypy/objspace/std/test/test_iterobject.py
--- a/pypy/objspace/std/test/test_iterobject.py
+++ b/pypy/objspace/std/test/test_iterobject.py
@@ -82,6 +82,17 @@
assert next(iterable) == 1
iterable.__setstate__(3)
assert next(iterable) == 4
+ iterable.__setstate__(-1)
+ raises(StopIteration, next, iterable)
+ #
+ iterable = reversed([1,2,3,4])
+ iterable.__setstate__(-100)
+ raises(StopIteration, next, iterable)
+ #
+ iterable = reversed([1,2,3,4])
+ iterable.__setstate__(100)
+ assert next(iterable) == 4
+ assert next(iterable) == 3
def test_forward_iter_reduce(self):
T = "abc"
More information about the pypy-commit
mailing list