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

Exhausted array iterator should left exhausted #70679

Closed
serhiy-storchaka opened this issue Mar 6, 2016 · 7 comments
Closed

Exhausted array iterator should left exhausted #70679

serhiy-storchaka opened this issue Mar 6, 2016 · 7 comments
Assignees
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Mar 6, 2016

BPO 26492
Nosy @rhettinger, @vstinner, @larryhastings, @benjaminp, @serhiy-storchaka
Files
  • exhausted_array_iterator.patch
  • exhausted_array_iterator2.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/rhettinger'
    closed_at = <Date 2016-03-31.12:18:36.830>
    created_at = <Date 2016-03-06.16:04:40.739>
    labels = ['extension-modules', 'type-bug']
    title = 'Exhausted array iterator should left exhausted'
    updated_at = <Date 2016-03-31.12:18:36.829>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-03-31.12:18:36.829>
    actor = 'serhiy.storchaka'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2016-03-31.12:18:36.830>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2016-03-06.16:04:40.739>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['42079', '42089']
    hgrepos = []
    issue_num = 26492
    keywords = ['patch']
    message_count = 7.0
    messages = ['261260', '261329', '261338', '261339', '261342', '261344', '262676']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'vstinner', 'larry', 'benjamin.peterson', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26492'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Mar 6, 2016

    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.

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Mar 6, 2016
    @benjaminp
    Copy link
    Contributor

    benjaminp commented Mar 8, 2016

    Can you add just one patch to seq_test.py?

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Mar 8, 2016

    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.

    @vstinner
    Copy link
    Member

    vstinner commented Mar 8, 2016

    I reviewed exhausted_array_iterator2.patch.

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Mar 8, 2016

    Thanks Victor. Answered you comments.

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Mar 8, 2016

    TODO: After resolving bpo-26494 add similar test for array.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 30, 2016

    New changeset 89ba67ee83d6 by Serhiy Storchaka in branch '3.5':
    Issue bpo-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 bpo-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 bpo-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 bpo-26492: Exhausted iterator of array.array now conforms with the behavior
    https://hg.python.org/cpython/rev/b6eebe7cf5ae

    @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
    extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants