[issue19414] OrderedDict.values() behavior for modified instance

Nikolaus Rath report at bugs.python.org
Wed Oct 30 20:43:18 CET 2013


Nikolaus Rath added the comment:

Hmm. I see your point. You might be right (I'm not fully convinced yet though), but this bug is probably not a good place to go into more detail about this.

So what would be the best way to fix the immediate problem this was originally about? Raise a RuntimeError (as Armin suggested), or just end the iteration? 

Note that RuntimeError would only be raised when the current element is removed from the dict, and the ordered dict would still tolerate other kinds of modifications.

Both variants would also be a change from previous behavior (were removing the current elements works as long as you do not remove the next one as well).

The minimally intrusive change would be to skip over elements that have been removed, but that comes at the expense of an additional membership test in each iteration.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19414>
_______________________________________


More information about the Python-bugs-list mailing list