Commits

Fred Drake committed da5eab3

Weak*Dictionary.update(): Fix calls to [].append() to only have one
parameter.

Weak*Dictionary.get(): Make the second parameter optional.

WeakKeyDictionary.has_key(), .keys(): Make these actually work!

Comments (0)

Files changed (1)

                 new[key] = o
         return new
 
-    def get(self, key, default):
+    def get(self, key, default=None):
         try:
             ref = self.data[key]
         except KeyError:
         for key, o in dict.items():
             def remove(o, data=d, key=key):
                 del data[key]
-            L.append(key, ref(o, remove))
+            L.append((key, ref(o, remove)))
         for key, r in L:
             d[key] = r
 
                 new[o] = value
         return new
 
-    def get(self, key, default):
+    def get(self, key, default=None):
         return self.data.get(ref(key),default)
 
+    def has_key(self, key):
+        return self.data.has_key(ref(key))
+
     def items(self):
         L = []
         for key, value in self.data.items():
                 L.append((o, value))
         return L
 
+    def keys(self):
+        L = []
+        for ref in self.data.keys():
+            o = ref()
+            if o is not None:
+                L.append(o)
+        return L
+
     def popitem(self):
         while 1:
             key, value = self.data.popitem()
         d = self.data
         L = []
         for key, value in dict.items():
-            L.append(ref(key, self._remove), value)
+            L.append((ref(key, self._remove), value))
         for key, r in L:
             d[key] = r