summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_range.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 13:47:57 (GMT)
committerKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 13:47:57 (GMT)
commit25dded041fe532fcb041b6e68582bf76b4968132 (patch)
tree3c70fceb3fe5ef98a17b85aa94704d20eb5a853d /Lib/test/test_range.py
parent4ca688edeb07de955e1ef67c11f0e327f12ffa6e (diff)
downloadcpython-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.py12
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: