[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

Nikolaus Rath report at bugs.python.org
Wed Jan 8 06:05:57 CET 2014


Nikolaus Rath added the comment:

I have attached a patch that fixes this issue. Looking at Raymonds  comments in issue 19332, I have kept new code out of the critical path in __iter__ and instead modified the __delitem__ method (I assume that an element is removed only once, but may be iterated over many times). The updated __delitem__ now also updates the prev and next links of the removed item itself. When the current item is removed during an iteration, the iteration thus stops.

I hope that's an acceptable solution.

----------
keywords: +patch
Added file: http://bugs.python.org/file33359/issue19414.diff

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


More information about the Python-bugs-list mailing list