diff options
Diffstat (limited to 'Lib/_weakrefset.py')
-rw-r--r-- | Lib/_weakrefset.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py index b267780..2a27684 100644 --- a/Lib/_weakrefset.py +++ b/Lib/_weakrefset.py @@ -51,10 +51,14 @@ class WeakSet: self.update(data) def _commit_removals(self): - l = self._pending_removals + pop = self._pending_removals.pop discard = self.data.discard - while l: - discard(l.pop()) + while True: + try: + item = pop() + except IndexError: + return + discard(item) def __iter__(self): with _IterationGuard(self): |