summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-19 11:10:43 -0700
committerRaymond Hettinger <python@rcn.com>2011-04-19 11:10:43 -0700
commit1cc986e4a7ef3d1d535f045069710f11f67d5a22 (patch)
tree637df436d6e285068e50f3c9303ed47ac361e696
parentf97255fd7c1d2b70dfe8032a54ce3ce0daf4cea3 (diff)
parent35b873a7b2b25bf90099b1d449a35d6ff695d02b (diff)
downloadcpython-git-1cc986e4a7ef3d1d535f045069710f11f67d5a22.tar.gz
Issue 11875: Keep OrderedDict's __reduce__ from temporarily mutating the object.
-rw-r--r--Lib/collections.py5
-rw-r--r--Misc/NEWS3
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/collections.py b/Lib/collections.py
index cde734debd..a1f789082b 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -154,10 +154,9 @@ class OrderedDict(dict):
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
- tmp = self.__map, self.__root, self.__hardroot
- del self.__map, self.__root, self.__hardroot
inst_dict = vars(self).copy()
- self.__map, self.__root, self.__hardroot = tmp
+ for k in vars(self.__class__()):
+ inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
diff --git a/Misc/NEWS b/Misc/NEWS
index c1fb1649d9..fe6ba0194b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -68,6 +68,9 @@ Library
- Issue #11852: Add missing imports and update tests.
+- Issue #11875: collections.OrderedDict's __reduce__ was temporarily
+ mutating the object instead of just working on a copy.
+
- Issue #11467: Fix urlparse behavior when handling urls which contains scheme
specific part only digits. Patch by Santoso Wijaya.