[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-03 Thread Eric Snow
Changes by Eric Snow : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___ Pyth

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0d8679858272 by Eric Snow in branch '3.5': Issue #24369: Defend against key-changes during iteration. https://hg.python.org/cpython/rev/0d8679858272 -- nosy: +python-dev ___ Python tracker

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: This patch looks correct. Go ahead and apply. -- assignee: rhettinger -> eric.snow ___ Python tracker ___ __

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-03 Thread Eric Snow
Eric Snow added the comment: Here's a patch that tracks changes to the C OrderedDict linked list, similar to how it's done in deque. I've left the pure Python OrderedDict alone. @Raymond, that state counter works great. :) -- keywords: +patch stage: test needed -> patch review Added f

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-02 Thread Eric Snow
Eric Snow added the comment: Sounds good. Thanks, Raymond. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: The C version should defend itself against any key-changes during iteration (see the state counter used in deque objects for an example of how to do this). The pure python version of OrderedDict has only minimal defenses against mutating during iteration,

[issue24369] Using OrderedDict.move_to_end during iteration is problematic.

2015-06-02 Thread Eric Snow
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