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

__length_hint__() of bytearray iterator can return negative integer #71630

Closed
serhiy-storchaka opened this issue Jul 2, 2016 · 4 comments
Closed
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 27443
Nosy @rhettinger, @serhiy-storchaka
Files
  • bytearray_iterator_length_hint.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 = None
    closed_at = <Date 2016-07-03.12:18:19.108>
    created_at = <Date 2016-07-02.19:53:54.043>
    labels = ['interpreter-core', 'type-bug']
    title = '__length_hint__() of bytearray iterator can return negative integer'
    updated_at = <Date 2016-07-03.12:18:19.107>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-07-03.12:18:19.107>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-07-03.12:18:19.108>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-07-02.19:53:54.043>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['43612']
    hgrepos = []
    issue_num = 27443
    keywords = ['patch']
    message_count = 4.0
    messages = ['269729', '269735', '269761', '269764']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27443'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    >>> ba = bytearray(b'ab')
    >>> it = iter(ba)
    >>> next(it)
    97
    >>> ba.clear()
    >>> list(it)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: __length_hint__() should return >= 0

    Proposed patch fixes this issue.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jul 2, 2016
    @rhettinger
    Copy link
    Contributor

    This patch looks correct. Nice catch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 3, 2016

    New changeset 6b084bb6c38b by Serhiy Storchaka in branch '3.5':
    Issue bpo-27443: __length_hint__() of bytearray itearator no longer return
    https://hg.python.org/cpython/rev/6b084bb6c38b

    New changeset 03192909160d by Serhiy Storchaka in branch 'default':
    Issue bpo-27443: __length_hint__() of bytearray itearator no longer return
    https://hg.python.org/cpython/rev/03192909160d

    @serhiy-storchaka
    Copy link
    Member Author

    Thanks Raymond.

    @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

    2 participants