[Python-checkins] cpython (3.5): Issue #29119: Fix weakref in OrderedDict.move_to_end(). Work by Andra Bogildea.

raymond.hettinger python-checkins at python.org
Sat Dec 31 14:03:25 EST 2016


https://hg.python.org/cpython/rev/19376765d7c3
changeset:   105909:19376765d7c3
branch:      3.5
parent:      105906:1a25c639f81e
user:        Raymond Hettinger <python at rcn.com>
date:        Sat Dec 31 12:01:59 2016 -0700
summary:
  Issue #29119: Fix weakref in OrderedDict.move_to_end(). Work by Andra Bogildea.

files:
  Lib/collections/__init__.py |  7 +++++--
  Misc/ACKS                   |  1 +
  Misc/NEWS                   |  4 ++++
  3 files changed, 10 insertions(+), 2 deletions(-)


diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -189,6 +189,7 @@
         link = self.__map[key]
         link_prev = link.prev
         link_next = link.next
+        soft_link = link_next.prev
         link_prev.next = link_next
         link_next.prev = link_prev
         root = self.__root
@@ -196,12 +197,14 @@
             last = root.prev
             link.prev = last
             link.next = root
-            last.next = root.prev = link
+            root.prev = soft_link
+            last.next = link
         else:
             first = root.next
             link.prev = root
             link.next = first
-            root.next = first.prev = link
+            first.prev = soft_link
+            root.next = link
 
     def __sizeof__(self):
         sizeof = _sys.getsizeof
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -156,6 +156,7 @@
 Paul Boddie
 Matthew Boedicker
 Robin Boerdijk
+Andra Bogildea
 David Bolen
 Wouter Bolsterlee
 Gawain Bolton
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -143,6 +143,10 @@
 - Issue #13051: Fixed recursion errors in large or resized
   curses.textpad.Textbox.  Based on patch by Tycho Andersen.
 
+- Issue #29119: Fix weakrefs in the pure python version of
+  collections.OrderedDict move_to_end() method.
+  Contributed by Andra Bogildea.
+
 - Issue #9770: curses.ascii predicates now work correctly with negative
   integers.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list