summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-12-31 12:01:59 -0700
committerRaymond Hettinger <python@rcn.com>2016-12-31 12:01:59 -0700
commit489e44b864d4030577299954377b35bd75140503 (patch)
tree9921a42422a0408074bc130ae092d3e98119835c
parentad26abba7cb612e4ff88b6d5cc02eb5249a7e0a7 (diff)
downloadcpython-489e44b864d4030577299954377b35bd75140503.tar.gz
Issue #29119: Fix weakref in OrderedDict.move_to_end(). Work by Andra Bogildea.
-rw-r--r--Lib/collections/__init__.py7
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS4
3 files changed, 10 insertions, 2 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index ebe8ee7a83..bea811db7f 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -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
diff --git a/Misc/ACKS b/Misc/ACKS
index 06c7a93bc0..59b7704b73 100644
--- 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
diff --git a/Misc/NEWS b/Misc/NEWS
index 9aa561fb26..0dd4ef10f5 100644
--- 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.