]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport gvanrossum's checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:29:01 +0000 (16:29 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:29:01 +0000 (16:29 +0000)
    revision 1.17 of weakref.py

SF patch 564549 (Erik Andersén).

The WeakKeyDictionary constructor didn't work when a dict arg was
given.  Fixed by moving a line.  Also adding a unit test.

Bugfix candidate.

Lib/weakref.py

index 967458d989dc115e68756037f711b7e223a63110..bc4d0aa3bbfbf69ea54fecb26231efe9ccc5d8eb 100644 (file)
@@ -144,12 +144,12 @@ class WeakKeyDictionary(UserDict.UserDict):
 
     def __init__(self, dict=None):
         self.data = {}
-        if dict is not None: self.update(dict)
         def remove(k, selfref=ref(self)):
             self = selfref()
             if self is not None:
                 del self.data[k]
         self._remove = remove
+        if dict is not None: self.update(dict)
 
     def __delitem__(self, key):
         for ref in self.data.iterkeys():