Message244718
While the dict/OrderedDict iterators already check for additions and deletions, using the OrderedDict.move_to_end during iteration can lead to surprising results.
The following results in an infinite loop:
od = OrderedDict.fromkeys('abc')
last = None
for k in od:
if last is not None:
od.move_to_end(last)
last = k
Ideally we could disallow changing order during iteration, just like we disallow deletion. Since we've gone 3 minor versions already, would it be too late to break backward compatibility on this point? |
|
Date |
User |
Action |
Args |
2015-06-03 00:12:18 | eric.snow | set | recipients:
+ eric.snow, rhettinger |
2015-06-03 00:12:18 | eric.snow | set | messageid: <1433290338.7.0.000891245826788.issue24369@psf.upfronthosting.co.za> |
2015-06-03 00:12:18 | eric.snow | link | issue24369 messages |
2015-06-03 00:12:18 | eric.snow | create | |
|