Message 62950 - Python tracker (original) (raw)
Attached patch addresses OP's issue:
$ ./python.exe bad_range.py [8, 9, 10, 11, 12, 13, 14, 15, 16, 17] here [18446744073709551616L, 18446744073709551617L, 18446744073709551618L, 18446744073709551619L, 18446744073709551620L, 18446744073709551621L, 18446744073709551622L, 18446744073709551623L, 18446744073709551624L, 18446744073709551625L] [18446744073709551616L, 18446744073709551617L, 18446744073709551618L, 18446744073709551619L, 18446744073709551620L, 18446744073709551621L, 18446744073709551622L, 18446744073709551623L, 18446744073709551624L, 18446744073709551625L]
The only existing test that fails is range(1e100, 1e101, 1e101) producing a TypeError. It will now produce
range(1e100, 1e101, 1e101) main:1: DeprecationWarning: integer argument expected, got float [10000000000000000159028911097599180468360808563945281389781327557747838 772170381060813469985856815104L]
Note that range(1e100, 1e101) would still fail:
range(1e100, 1e101) Traceback (most recent call last): File "", line 1, in OverflowError: range() result has too many items
An alternative solution would be to disallow non-ints regardless of their value, but that is more likely to break someone's code.