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: __length_hint__() of bytearray iterator can return negative integer
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-07-02 19:53 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bytearray_iterator_length_hint.patch serhiy.storchaka, 2016-07-02 19:53 review
Messages (4)
msg269729 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-07-02 19:53
>>> 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.
msg269735 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-07-02 20:34
This patch looks correct.  Nice catch.
msg269761 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-07-03 11:42
New changeset 6b084bb6c38b by Serhiy Storchaka in branch '3.5':
Issue #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 #27443: __length_hint__() of bytearray itearator no longer return
https://hg.python.org/cpython/rev/03192909160d
msg269764 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-07-03 12:18
Thanks Raymond.
History
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71630
2016-07-03 12:18:19serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg269764

stage: patch review -> resolved
2016-07-03 11:42:43python-devsetnosy: + python-dev
messages: + msg269761
2016-07-02 20:34:54rhettingersetmessages: + msg269735
2016-07-02 19:53:54serhiy.storchakacreate