]> granicus.if.org Git - python/commitdiff
Fix two issues in the weak set implementation.
authorGeorg Brandl <georg@python.org>
Sun, 18 May 2008 07:46:13 +0000 (07:46 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 18 May 2008 07:46:13 +0000 (07:46 +0000)
Lib/_weakrefset.py

index e56ac048dd571f37c2e1997481263aa8a2df01e6..a6827e8298ec93201568c00991ea52e5f600c460 100644 (file)
@@ -41,7 +41,10 @@ class WeakSet:
 
     def pop(self):
         while True:
-            itemref = self.data.pop()
+            try:
+                itemref = self.data.pop()
+            except KeyError:
+                raise KeyError('pop from empty WeakSet')
             item = itemref()
             if item is not None:
                 return item
@@ -107,5 +110,5 @@ class WeakSet:
     __ixor__ = symmetric_difference_update
 
     def union(self, other):
-        self._apply_mutate(other, self.data.union)
+        return self._apply(other, self.data.union)
     __or__ = union