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

bytearray.remove cannot remove bytes with value greater than 127 #71226

Closed
DamienGeorge mannequin opened this issue May 16, 2016 · 8 comments
Closed

bytearray.remove cannot remove bytes with value greater than 127 #71226

DamienGeorge mannequin opened this issue May 16, 2016 · 8 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@DamienGeorge
Copy link
Mannequin

DamienGeorge mannequin commented May 16, 2016

BPO 27039
Nosy @serhiy-storchaka, @llllllllll
Files
  • bytearray-remove.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/serhiy-storchaka'
    closed_at = <Date 2016-05-16.19:25:52.579>
    created_at = <Date 2016-05-16.16:29:48.584>
    labels = ['interpreter-core', 'type-bug']
    title = 'bytearray.remove cannot remove bytes with value greater than 127'
    updated_at = <Date 2016-05-16.19:25:52.578>
    user = 'https://bugs.python.org/DamienGeorge'

    bugs.python.org fields:

    activity = <Date 2016-05-16.19:25:52.578>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-05-16.19:25:52.579>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-05-16.16:29:48.584>
    creator = 'Damien George'
    dependencies = []
    files = ['42875']
    hgrepos = []
    issue_num = 27039
    keywords = ['patch']
    message_count = 8.0
    messages = ['265709', '265711', '265714', '265717', '265719', '265720', '265722', '265726']
    nosy_count = 5.0
    nosy_names = ['SilentGhost', 'python-dev', 'serhiy.storchaka', 'llllllllll', 'Damien George']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27039'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @DamienGeorge
    Copy link
    Mannequin Author

    DamienGeorge mannequin commented May 16, 2016

    The following code fails with a ValueError (but I expect it to succeed):

    >> bytearray([128]).remove(128)

    Tested with Python 2.7.11 and 3.5.1. Probably it's a case of comparing a char (signed byte) with an unsigned value.

    @DamienGeorge DamienGeorge mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 16, 2016
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented May 16, 2016

    Test is not catching it, because it only deals with ascii part.

    @llllllllll
    Copy link
    Mannequin

    llllllllll mannequin commented May 16, 2016

    This seems to just be a bug in the implementation of remove. I have a patch to fix this and a test case.

    @serhiy-storchaka
    Copy link
    Member

    LGTM.

    @serhiy-storchaka serhiy-storchaka self-assigned this May 16, 2016
    @serhiy-storchaka
    Copy link
    Member

    But we first need to test that value is in the range from 0 to 255.

    1 similar comment
    @serhiy-storchaka
    Copy link
    Member

    But we first need to test that value is in the range from 0 to 255.

    @serhiy-storchaka
    Copy link
    Member

    Ah, this is already checked in the converter.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 16, 2016

    New changeset 10444778d41c by Serhiy Storchaka in branch '3.5':
    Issue bpo-27039: Fixed bytearray.remove() for values greater than 127.
    https://hg.python.org/cpython/rev/10444778d41c

    New changeset 9acf44b7ff7b by Serhiy Storchaka in branch '2.7':
    Issue bpo-27039: Fixed bytearray.remove() for values greater than 127.
    https://hg.python.org/cpython/rev/9acf44b7ff7b

    New changeset 3eb502d43616 by Serhiy Storchaka in branch 'default':
    Issue bpo-27039: Fixed bytearray.remove() for values greater than 127.
    https://hg.python.org/cpython/rev/3eb502d43616

    @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