summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/collections/__init__.py5
-rw-r--r--Misc/NEWS3
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index a6bcaea..32c2e80 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -155,10 +155,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 62eb3ab..27be0cc 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -121,6 +121,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.