diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 15:23:07 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 15:23:07 (GMT) |
commit | c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a (patch) | |
tree | 21c775f7b89e60348ed587d1bb983b2cd61e723b /Lib/test | |
parent | 25ea45db81540b8c589c65edf2564c04461b1f34 (diff) | |
parent | 25dded041fe532fcb041b6e68582bf76b4968132 (diff) | |
download | cpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.zip cpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.tar.gz cpython-c5cc5011ac33f96a8bf28e3ba088980fd5e71d7a.tar.bz2 |
Make the various iterators' "setstate" sliently and consistently clip the
index. This avoids the possibility of setting an iterator to an invalid
state.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_range.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 64b6a77..fecda1b 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -381,6 +381,18 @@ class RangeTest(unittest.TestCase): self.assertEqual(list(it), data[1:]) def test_exhausted_iterator_pickling(self): + r = range(2**65, 2**65+2) + i = iter(r) + while True: + r = next(i) + if r == 2**65+1: + break + d = pickle.dumps(i) + i2 = pickle.loads(d) + self.assertEqual(list(i), []) + self.assertEqual(list(i2), []) + + def test_large_exhausted_iterator_pickling(self): r = range(20) i = iter(r) while True: |