diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2014-03-04 23:19:24 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2014-03-04 23:19:24 (GMT) |
commit | 4ca688edeb07de955e1ef67c11f0e327f12ffa6e (patch) | |
tree | 27fa902c07258b5749d0984566d7df4ba73d740d /Lib/test/test_range.py | |
parent | 682ea5f70e5450ffd5a50ef7f39d65c2faeb6b63 (diff) | |
download | cpython-4ca688edeb07de955e1ef67c11f0e327f12ffa6e.zip cpython-4ca688edeb07de955e1ef67c11f0e327f12ffa6e.tar.gz cpython-4ca688edeb07de955e1ef67c11f0e327f12ffa6e.tar.bz2 |
Fix pickling of rangeiter. rangeiter_setstate would not allow setting it
to the exhausted 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 2a13bfe..063f320 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -379,6 +379,18 @@ class RangeTest(unittest.TestCase): it = pickle.loads(d) self.assertEqual(list(it), data[1:]) + def test_exhausted_iterator_pickling(self): + r = range(20) + i = iter(r) + while True: + r = next(i) + if r == 19: + break + d = pickle.dumps(i) + i2 = pickle.loads(d) + self.assertEqual(list(i), []) + self.assertEqual(list(i2), []) + def test_odd_bug(self): # This used to raise a "SystemError: NULL result without error" # because the range validation step was eating the exception |