Kaydet (Commit) d08a2c25 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue 11875: Keep OrderedDict's __reduce__ from temporarily mutating the object.

üst 2876a8c2
...@@ -101,10 +101,9 @@ class OrderedDict(dict): ...@@ -101,10 +101,9 @@ class OrderedDict(dict):
def __reduce__(self): def __reduce__(self):
'Return state information for pickling' 'Return state information for pickling'
items = [[k, self[k]] for k in self] items = [[k, self[k]] for k in self]
tmp = self.__map, self.__root, self.__in_repr
del self.__map, self.__root, self.__in_repr
inst_dict = vars(self).copy() inst_dict = vars(self).copy()
self.__map, self.__root, self.__in_repr = tmp for k in vars(self.__class__()):
inst_dict.pop(k, None)
if inst_dict: if inst_dict:
return (self.__class__, (items,), inst_dict) return (self.__class__, (items,), inst_dict)
return self.__class__, (items,) return self.__class__, (items,)
......
...@@ -58,6 +58,9 @@ Library ...@@ -58,6 +58,9 @@ Library
- Issue #11467: Fix urlparse behavior when handling urls which contains scheme - Issue #11467: Fix urlparse behavior when handling urls which contains scheme
specific part only digits. Patch by Santoso Wijaya. specific part only digits. Patch by Santoso Wijaya.
- Issue #11875: collections.OrderedDict's __reduce__ was temporarily
mutating the object instead of just working on a copy.
- collections.Counter().copy() now works correctly for subclasses. - collections.Counter().copy() now works correctly for subclasses.
- Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows. - Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment