diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 13:47:57 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2014-03-05 13:47:57 (GMT) |
commit | 25dded041fe532fcb041b6e68582bf76b4968132 (patch) | |
tree | 3c70fceb3fe5ef98a17b85aa94704d20eb5a853d /Lib/test/test_range.py | |
parent | 4ca688edeb07de955e1ef67c11f0e327f12ffa6e (diff) | |
download | cpython-25dded041fe532fcb041b6e68582bf76b4968132.zip cpython-25dded041fe532fcb041b6e68582bf76b4968132.tar.gz cpython-25dded041fe532fcb041b6e68582bf76b4968132.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/test_range.py')
-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 063f320..aab98ab 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -380,6 +380,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: |