Issue 26492: Exhausted array iterator should left exhausted (original) (raw)

Created on 2016-03-06 16:04 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
exhausted_array_iterator.patch serhiy.storchaka,2016-03-06 16:04 review
exhausted_array_iterator2.patch serhiy.storchaka,2016-03-08 09:38 review
Messages (7)
msg261260 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-06 16:04
There is general rule that after raising StopIteration the iterator should always raise StopIteration even if new data is added to iterating sequence. Array iterators don't obey this rule. Proposed patch makes array iterator to left in exhausted state since it achieved. As a side (or may be primary) effect of this change, iterating sequence can be freed just after iterating is finished. Added tests for other iterators of resizable sequences. I don't know whether this patch should be applied to maintained releases or only to default branch. Note that array pickling tests broken by this patch were just added. They just expose current (presumably incorrect) behavior.
msg261329 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2016-03-08 06:37
Can you add just one patch to seq_test.py?
msg261338 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-08 09:38
Thanks for suggestion Benjamin. seq_tests.py provides common tests for list, tuple, UserList and deque. This test doesn't work for tuple, since it is not mutable. It doesn't work for deque, since it can't be iterated after changing size. Common test for list and UserList can be moved to list_tests.py. In any case we need separate tests for bytearray, array and general sequence iterator. I would be happy to not repeat the test, but tests for array and general sequence iterator have not much common with test for list. Updated patch moves list test to list_tests.py (it now works for UserList) and reuses in for bytearray.
msg261339 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-08 10:42
I reviewed exhausted_array_iterator2.patch.
msg261342 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-08 10:57
Thanks Victor. Answered you comments.
msg261344 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-08 11:01
TODO: After resolving add similar test for array.
msg262676 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-30 18:11
New changeset 89ba67ee83d6 by Serhiy Storchaka in branch '3.5': Issue #26492: Added additional tests for exhausted iterators of mutable sequences. https://hg.python.org/cpython/rev/89ba67ee83d6 New changeset b4ea00d50e7e by Serhiy Storchaka in branch 'default': Issue #26492: Added additional tests for exhausted iterators of mutable sequences. https://hg.python.org/cpython/rev/b4ea00d50e7e New changeset 249ef9d02aa6 by Serhiy Storchaka in branch '2.7': Issue #26492: Added additional tests for exhausted iterators of mutable sequences. https://hg.python.org/cpython/rev/249ef9d02aa6 New changeset b6eebe7cf5ae by Serhiy Storchaka in branch 'default': Issue #26492: Exhausted iterator of array.array now conforms with the behavior https://hg.python.org/cpython/rev/b6eebe7cf5ae
History
Date User Action Args
2022-04-11 14:58:28 admin set github: 70679
2016-03-31 12🔞36 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2016-03-30 18:11:50 python-dev set nosy: + python-devmessages: +
2016-03-08 11:01:56 serhiy.storchaka set messages: +
2016-03-08 10:57:36 serhiy.storchaka set messages: +
2016-03-08 10:42:37 vstinner set nosy: + vstinnermessages: +
2016-03-08 09:38:41 serhiy.storchaka set files: + exhausted_array_iterator2.patchmessages: +
2016-03-08 06:37:01 benjamin.peterson set messages: +
2016-03-06 16:04:40 serhiy.storchaka create