Hold key reference until the links have updated.

This commit is contained in:
Raymond Hettinger 2013-03-23 05:27:51 -07:00
parent bb2dad8915
commit 5ded795a72

View file

@ -66,7 +66,7 @@ class OrderedDict(dict):
# Deleting an existing item uses self.__map to find the link which gets # Deleting an existing item uses self.__map to find the link which gets
# removed by updating the links in the predecessor and successor nodes. # removed by updating the links in the predecessor and successor nodes.
dict_delitem(self, key) dict_delitem(self, key)
link_prev, link_next, key = self.__map.pop(key) link_prev, link_next, _ = self.__map.pop(key)
link_prev[1] = link_next # update link_prev[NEXT] link_prev[1] = link_next # update link_prev[NEXT]
link_next[0] = link_prev # update link_next[PREV] link_next[0] = link_prev # update link_next[PREV]