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

Fix exception thrown by bytearray.pop() for empty bytearrays #55595

Closed
elibendersky mannequin opened this issue Mar 3, 2011 · 9 comments
Closed

Fix exception thrown by bytearray.pop() for empty bytearrays #55595

elibendersky mannequin opened this issue Mar 3, 2011 · 9 comments
Assignees
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@elibendersky
Copy link
Mannequin

elibendersky mannequin commented Mar 3, 2011

BPO 11386
Nosy @birkenfeld, @rhettinger, @terryjreedy, @ncoghlan
Files
  • issue11386.1.patch
  • 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/rhettinger'
    closed_at = <Date 2011-03-04.05:18:47.219>
    created_at = <Date 2011-03-03.18:29:03.072>
    labels = ['interpreter-core', 'easy', 'type-bug']
    title = 'Fix exception thrown by bytearray.pop() for empty bytearrays'
    updated_at = <Date 2011-03-04.06:15:23.489>
    user = 'https://bugs.python.org/elibendersky'

    bugs.python.org fields:

    activity = <Date 2011-03-04.06:15:23.489>
    actor = 'eli.bendersky'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2011-03-04.05:18:47.219>
    closer = 'eli.bendersky'
    components = ['Interpreter Core']
    creation = <Date 2011-03-03.18:29:03.072>
    creator = 'eli.bendersky'
    dependencies = []
    files = ['20986']
    hgrepos = []
    issue_num = 11386
    keywords = ['patch', 'easy', 'needs review']
    message_count = 9.0
    messages = ['129989', '129992', '129996', '130020', '130021', '130022', '130023', '130027', '130030']
    nosy_count = 6.0
    nosy_names = ['nnorwitz', 'georg.brandl', 'rhettinger', 'terry.reedy', 'ncoghlan', 'eli.bendersky']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11386'
    versions = ['Python 3.3']

    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 3, 2011

    bytearray.pop() currently throws OverflowError when popping an empty bytearray, instead of IndexError.

    See Issue bpo-10516 for reference discussion.

    @elibendersky elibendersky mannequin assigned rhettinger Mar 3, 2011
    @elibendersky elibendersky mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) easy type-bug An unexpected behavior, bug, or error labels Mar 3, 2011
    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 3, 2011

    The attached patch changes the exception thrown to IndexError, as well as aligning the error message to the one thrown by list.

    @rhettinger
    Copy link
    Contributor

    The patch looks fine. Please apply and backport.

    Also, please search all other pop() methods in the standard library to see if this bug occurred anywhere else. Popping from an empty container should be a LookupError, either IndexError for sequences or KeyError for mappings.

    @rhettinger rhettinger assigned elibendersky and unassigned rhettinger Mar 3, 2011
    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 4, 2011

    Committed into py3k, revision 88735

    @elibendersky elibendersky mannequin assigned rhettinger and unassigned elibendersky Mar 4, 2011
    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 4, 2011

    Committed into release32-maint, revision 88739

    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 4, 2011

    Can't find other instances of this bug, so I'm closing the issue.

    @elibendersky elibendersky mannequin closed this as completed Mar 4, 2011
    @rhettinger
    Copy link
    Contributor

    Does Python 2.7 have an issue?

    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 4, 2011

    Indeed it does - good catch :-)
    I'll backport to 2.7 soon

    @elibendersky
    Copy link
    Mannequin Author

    elibendersky mannequin commented Mar 4, 2011

    Committed to release27-maint, revision 88741

    @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
    easy 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