• Guido van Rossum's avatar
    SF patch #103158 by Greg Ball: Don't do unsafe arithmetic in xrange · 65e0b99b
    Guido van Rossum yazdı
    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...
    65e0b99b
rangeobject.c 6.5 KB