Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xrange repr broken for large arguments #60234

Closed
mdickinson opened this issue Sep 24, 2012 · 3 comments
Closed

xrange repr broken for large arguments #60234

mdickinson opened this issue Sep 24, 2012 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@mdickinson
Copy link
Member

BPO 16030
Nosy @mdickinson, @vstinner
Dependencies
  • bpo-16029: pickle.dumps(xrange(sys.maxsize)) produces xrange(0)
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/mdickinson'
    closed_at = <Date 2012-09-28.19:51:15.088>
    created_at = <Date 2012-09-24.21:23:17.295>
    labels = ['interpreter-core', 'type-bug']
    title = 'xrange repr broken for large arguments'
    updated_at = <Date 2012-09-28.19:51:15.087>
    user = 'https://github.com/mdickinson'

    bugs.python.org fields:

    activity = <Date 2012-09-28.19:51:15.087>
    actor = 'mark.dickinson'
    assignee = 'mark.dickinson'
    closed = True
    closed_date = <Date 2012-09-28.19:51:15.088>
    closer = 'mark.dickinson'
    components = ['Interpreter Core']
    creation = <Date 2012-09-24.21:23:17.295>
    creator = 'mark.dickinson'
    dependencies = ['16029']
    files = []
    hgrepos = []
    issue_num = 16030
    keywords = []
    message_count = 3.0
    messages = ['171193', '171266', '171534']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'vstinner', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16030'
    versions = ['Python 2.7']

    @mdickinson
    Copy link
    Member Author

    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 bpo-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.

    @mdickinson mdickinson added the stdlib Python modules in the Lib dir label Sep 24, 2012
    @mdickinson mdickinson self-assigned this Sep 24, 2012
    @mdickinson mdickinson added the type-bug An unexpected behavior, bug, or error label Sep 24, 2012
    @mdickinson
    Copy link
    Member Author

    The patch for issue bpo-16029 fixes this issue, too.

    @mdickinson mdickinson added interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed stdlib Python modules in the Lib dir labels Sep 25, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 28, 2012

    New changeset bff269ee7288 by Mark Dickinson in branch '2.7':
    Issues bpo-16029, bpo-16030: Fix pickling and repr of large xranges.
    http://hg.python.org/cpython/rev/bff269ee7288

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant