diff --git a/Lib/collections.py b/Lib/collections.py index 1f1f51072b5..79f6696bb83 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -107,8 +107,14 @@ class OrderedDict(dict, MutableMapping): def clear(self): 'od.clear() -> None. Remove all items from od.' - for k in dict.keys(self): - del self[k] + try: + for node in self.__map.itervalues(): + del node[:] + self.__root[:] = [self.__root, self.__root, None] + self.__map.clear() + except AttributeError: + pass + dict.clear(self) setdefault = MutableMapping.setdefault update = MutableMapping.update