This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Discrepancy between iterating empty and non-empty deques
Type: Stage:
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, tzot
Priority: normal Keywords:

Created on 2007-01-09 20:26 by tzot, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg30963 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2007-01-09 20:26
>>> 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.
msg30964 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2007-01-09 20:29
Assigned to Raymond as requested in http://mail.python.org/pipermail/python-dev/2007-January/070528.html
msg30965 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-01-09 20:46
Fixed in rev 53299,
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44436
2007-01-09 20:26:00tzotcreate