Matthew Brett added the comment:
To clarify from comments on issue 19332:
"""
* The normal rule (not just for Python) is that a data structures have
undefined behavior for mutating while iterating, unless there is a specific
guarantee
"""
The change in Python 3.6 is just a different undefined
R. David Murray added the comment:
This "bug" has always existed, its just that its manifestation has changed.
See issue 19332 for background.
--
nosy: +r.david.murray
resolution: -> duplicate
stage: -> resolved
status: open -> closed
superseder: -> Guard against changing dict durin
New submission from Matthew Brett:
The behavior of dict iteration has changed in Python 3.6, in that inserting
keys during iteration has a different and unpredictable affect. For this code:
d = {'foo': 1}
for key in d:
print(key)
d.pop(key)
d[key] = 1
Python 3.5 prints a single 'foo'