diff --git a/Lib/collections.py b/Lib/collections.py index 40289836853..a1e8ed975bf 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -58,9 +58,13 @@ def popitem(self): def __reduce__(self): items = [[k, self[k]] for k in self] + tmp = self.__keys + del self.__keys inst_dict = vars(self).copy() - inst_dict.pop('__keys', None) - return (self.__class__, (items,), inst_dict) + self.__keys = tmp + if inst_dict: + return (self.__class__, (items,), inst_dict) + return self.__class__, (items,) setdefault = MutableMapping.setdefault update = MutableMapping.update