SF patch #103158 by Greg Ball: Don't do unsafe arithmetic in xrange
object. This fixes potential overflows in xrange()'s internal calculations on 64-bit platforms. The fix is complicated because the sq_length slot function can only return an int; we want to support xrange(sys.maxint), which is a 64-bit quantity on most 64-bit platforms (except Win64). The solution is hacky but the best possible: when the range is that long, we can use it in a for loop but we can't ask for its length (nor can we actually iterate beyond 2**31-1, because the sq_item slot function has the same restrictions on its arguments. Fixing those restrictions is a project for another day...
G
Guido van Rossum committed
65e0b99b611a42fd6548b2783a234f32630e6f1b
Parent: afc4f04