Fix-up __reduce__ which could not reach the __keys variable indirectly.'

This commit is contained in:
Raymond Hettinger 2009-03-03 22:20:56 +00:00
parent 9a572ba966
commit 14b89ffc7e
1 changed files with 6 additions and 2 deletions

View 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