]> granicus.if.org Git - python/commitdiff
Issue #29119: Fix weakref in OrderedDict.move_to_end(). Work by Andra Bogildea.
authorRaymond Hettinger <python@rcn.com>
Sat, 31 Dec 2016 19:01:59 +0000 (12:01 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 31 Dec 2016 19:01:59 +0000 (12:01 -0700)
Lib/collections/__init__.py
Misc/ACKS
Misc/NEWS

index ebe8ee7a838a38d9692bb919167cd2194a5d7bb8..bea811db7fa657b08170472b46cb616d030e5adc 100644 (file)
@@ -189,6 +189,7 @@ class OrderedDict(dict):
         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 @@ class OrderedDict(dict):
             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
index 06c7a93bc0151af5e0bb45eace44ba5a83dc0eb5..59b7704b73e354ec6e89c1f7b130b9480e817e84 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -156,6 +156,7 @@ Finn Bock
 Paul Boddie
 Matthew Boedicker
 Robin Boerdijk
+Andra Bogildea
 David Bolen
 Wouter Bolsterlee
 Gawain Bolton
index 9aa561fb26538429e8e6d23b3d049a9b2c36970b..0dd4ef10f5d7e4b1d4546a079bb66993a855f32b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -143,6 +143,10 @@ Library
 - 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.