]> granicus.if.org Git - python/commitdiff
Fix-up __reduce__ which could not reach the __keys variable indirectly.'
authorRaymond Hettinger <python@rcn.com>
Tue, 3 Mar 2009 22:20:56 +0000 (22:20 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 3 Mar 2009 22:20:56 +0000 (22:20 +0000)
Lib/collections.py

index 4028983685304e20b7ac8cd1ee410594f03a0b99..a1e8ed975bf8de104a8b392f7e252423c803cec5 100644 (file)
@@ -58,9 +58,13 @@ class OrderedDict(dict, MutableMapping):
 
     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