This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xrange repr broken for large arguments
Type: behavior Stage: needs patch
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: 16029 Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson, python-dev, vstinner
Priority: normal Keywords:

Created on 2012-09-24 21:23 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg171193 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-09-24 21:23
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.
msg171266 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-09-25 13:13
The patch for issue #16029 fixes this issue, too.
msg171534 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-09-28 19:49
New changeset bff269ee7288 by Mark Dickinson in branch '2.7':
Issues #16029, #16030: Fix pickling and repr of large xranges.
http://hg.python.org/cpython/rev/bff269ee7288
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60234
2012-09-28 19:51:15mark.dickinsonsetstatus: open -> closed
resolution: fixed
2012-09-28 19:49:00python-devsetnosy: + python-dev
messages: + msg171534
2012-09-25 13:13:11mark.dickinsonsetdependencies: + pickle.dumps(xrange(sys.maxsize)) produces xrange(0)
messages: + msg171266
components: + Interpreter Core, - Library (Lib)
2012-09-25 00:08:16vstinnersetnosy: + vstinner
2012-09-24 21:23:17mark.dickinsoncreate