]> granicus.if.org Git - python/commitdiff
Move initialization of root link to __init__.
authorRaymond Hettinger <python@rcn.com>
Mon, 23 Mar 2009 04:42:18 +0000 (04:42 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 23 Mar 2009 04:42:18 +0000 (04:42 +0000)
Lib/collections.py

index 2c2355ee1e8b9580cbdc918c7572273c0fa6ba83..f0f1fbbe29030e5b2ad352d8b6e6f58ccceedaf8 100644 (file)
@@ -41,11 +41,12 @@ class OrderedDict(dict, MutableMapping):
         try:
             self.__root
         except AttributeError:
+            self.__root = _Link()       # sentinel node for the doubly linked list
             self.clear()
         self.update(*args, **kwds)
 
     def clear(self):
-        self.__root = root = _Link()    # sentinel node for the doubly linked list
+        root = self.__root
         root.prev = root.next = root
         self.__map = {}
         dict.clear(self)