Author matthew.brett
Recipients matthew.brett
Date 2017-02-02.14:10:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:
   d[key] = 1

Python 3.5 prints a single 'foo' (one pass through the loop).  Python 3.6 generates five lines of 'foo' (five passes through the loop).  Of course this code is pathological, but I found this behavior from a bug in code where the pathology was a lot less obvious - see
Date User Action Args
2017-02-02 14:10:45matthew.brettsetrecipients: + matthew.brett
2017-02-02 14:10:45matthew.brettsetmessageid: <>
2017-02-02 14:10:45matthew.brettlinkissue29420 messages
2017-02-02 14:10:45matthew.brettcreate