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.
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.