Message286794
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' (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 https://github.com/nipy/nipy/issues/420 |
|
Date |
User |
Action |
Args |
2017-02-02 14:10:45 | matthew.brett | set | recipients:
+ matthew.brett |
2017-02-02 14:10:45 | matthew.brett | set | messageid: <1486044645.48.0.643305374135.issue29420@psf.upfronthosting.co.za> |
2017-02-02 14:10:45 | matthew.brett | link | issue29420 messages |
2017-02-02 14:10:45 | matthew.brett | create | |
|