[New-bugs-announce] [issue24369] Using OrderedDict.move_to_end during iteration is problematic.
Eric Snow
report at bugs.python.org
Wed Jun 3 02:12:18 CEST 2015
New submission from Eric Snow:
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?
----------
components: Library (Lib)
messages: 244718
nosy: eric.snow, rhettinger
priority: high
severity: normal
stage: test needed
status: open
title: Using OrderedDict.move_to_end during iteration is problematic.
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24369>
_______________________________________
More information about the New-bugs-announce
mailing list