diff options
-rw-r--r-- | Lib/collections.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 1f1f510..79f6696 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 |