diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-09-04 18:02:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-04 18:02:21 (GMT) |
commit | 936f6a16b9ef85bd56b18a247b962801e954c30e (patch) | |
tree | b28e59c8374f6a8ed06de4bf091a26628feac1bb /Lib/test/test_range.py | |
parent | c2970fdec52788b6d9ff419ab7e31f255d87433d (diff) | |
download | cpython-936f6a16b9ef85bd56b18a247b962801e954c30e.zip cpython-936f6a16b9ef85bd56b18a247b962801e954c30e.tar.gz cpython-936f6a16b9ef85bd56b18a247b962801e954c30e.tar.bz2 |
bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000)
It happened with fast range iterator when the calculated stop = start + step * len
was out of the C long range.
Diffstat (limited to 'Lib/test/test_range.py')
-rw-r--r-- | Lib/test/test_range.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 897162b..851ad5b 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -375,8 +375,14 @@ class RangeTest(unittest.TestCase): def test_iterator_pickling(self): testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1), (13, 21, 3), - (-2, 2, 2), (2**31-3, 2**31-1), (2**33, 2**33+2), - (2**63-3, 2**63-1), (2**65, 2**65+2)] + (-2, 2, 2)] + for M in 2**31, 2**63: + testcases += [ + (M-3, M-1), (4*M, 4*M+2), + (M-2, M-1, 2), (-M+1, -M, -2), + (1, 2, M-1), (-1, -2, -M), + (1, M-1, M-1), (-1, -M, -M), + ] for proto in range(pickle.HIGHEST_PROTOCOL + 1): for t in testcases: with self.subTest(proto=proto, t=t): |