-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Exhausted array iterator should left exhausted #70679
Comments
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. |
Can you add just one patch to seq_test.py? |
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. |
I reviewed exhausted_array_iterator2.patch. |
Thanks Victor. Answered you comments. |
TODO: After resolving bpo-26494 add similar test for array. |
New changeset 89ba67ee83d6 by Serhiy Storchaka in branch '3.5': New changeset b4ea00d50e7e by Serhiy Storchaka in branch 'default': New changeset 249ef9d02aa6 by Serhiy Storchaka in branch '2.7': New changeset b6eebe7cf5ae by Serhiy Storchaka in branch 'default': |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: