summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_range.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_range.py')
-rw-r--r--Lib/test/test_range.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index d9d4cf8..fecda1b 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -380,6 +380,30 @@ class RangeTest(unittest.TestCase):
it = pickle.loads(d)
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:
+ 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