summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-06-24 18:36:46 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-06-24 18:36:46 (GMT)
commiteb36d31bb8d0fdf4be14fd14deaf88149e771417 (patch)
treeaaa34d5cfebafef2da73e7c93652ca5a04676a11 /Lib/test
parenteeb575f3290802bb542ad5f7442822586c8c08cf (diff)
downloadcpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.zip
cpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.tar.gz
cpython-eb36d31bb8d0fdf4be14fd14deaf88149e771417.tar.bz2
Issue #6334: Fix buggy internal length calculation in builtin range function
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_builtin.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index a62e124..fdb0ea2 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -924,6 +924,24 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(list(range(1, 10, 3)), [1, 4, 7])
#self.assertEqual(list(range(5, -5, -3)), [5, 2, -1, -4])
+ #issue 6334: the internal stored range length was being
+ #computed incorrectly in some cases involving large arguments.
+ x = range(10**20, 10**20+10, 3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
+ x = range(10**20+10, 10**20, 3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20, 10**20+10, -3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20+10, 10**20, -3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
""" XXX(nnorwitz):
# Now test range() with longs
self.assertEqual(list(range(-2**100)), [])