From 4ca688edeb07de955e1ef67c11f0e327f12ffa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 4 Mar 2014 23:19:24 +0000 Subject: Fix pickling of rangeiter. rangeiter_setstate would not allow setting it to the exhausted state. --- Lib/test/test_range.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_range.py') diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 2a13bfeabd..063f320bfe 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 -- cgit v1.2.1