Skip to content

Commit bf93b04

Browse files
committed
Fix two issues in the weak set implementation.
1 parent e624d17 commit bf93b04

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/_weakrefset.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def copy(self):
4141

4242
def pop(self):
4343
while True:
44-
itemref = self.data.pop()
44+
try:
45+
itemref = self.data.pop()
46+
except KeyError:
47+
raise KeyError('pop from empty WeakSet')
4548
item = itemref()
4649
if item is not None:
4750
return item
@@ -107,5 +110,5 @@ def symmetric_difference_update(self, other):
107110
__ixor__ = symmetric_difference_update
108111

109112
def union(self, other):
110-
self._apply_mutate(other, self.data.union)
113+
return self._apply(other, self.data.union)
111114
__or__ = union

0 commit comments

Comments
 (0)