Issue 16030: xrange repr broken for large arguments (original) (raw)

Python 2.7.3+ (2.7:f51d11405f1d+, Sep 24 2012, 21:39:19) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import sys xrange(0, sys.maxint, sys.maxint-1) xrange(0, -4, 9223372036854775806)

See also issue #16029. There should be a common solution to both these issues. Suggestion is to write a 'range_safe_stop' utility function that returns r->start + r->len * r->step clipped to the range [LONG_MIN, LONG_MAX], and use that for the stop value in both the repr and the pickle.