[ python-Bugs-1631769 ] Discrepancy between iterating empty and non-empty deques

SourceForge.net noreply at sourceforge.net
Tue Jan 9 21:26:01 CET 2007


Bugs item #1631769, was opened at 2007-01-09 22:26
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1631769&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Christos Georgiou (tzot)
Assigned to: Nobody/Anonymous (nobody)
Summary: Discrepancy between iterating empty and non-empty deques

Initial Comment:
>>> from collections import deque
>>> empty= deque()
>>> nonempty= deque([None])
>>> iter_empty= iter(empty)
>>> iter_nonempty= iter(nonempty)
>>> empty.append(1)
>>> nonempty.append(1)
>>> iter_empty.next()

Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    iter_empty.next()
StopIteration
>>> iter_nonempty.next()

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    iter_nonempty.next()
RuntimeError: deque mutated during iteration
>>> 

If the RuntimeError is the intended behaviour for a modified deque after its iterator has been created, then iter_empty.next() should also raise the same RuntimeError.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1631769&group_id=5470


More information about the Python-bugs-list mailing list