summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Shadura <andrew.shadura@collabora.co.uk>2018-07-08 09:00:16 +0200
committerAndrej Shadura <andrew.shadura@collabora.co.uk>2018-07-08 09:03:18 +0200
commit74604df9d213e434ce7a6720e771f068b2144211 (patch)
tree755d57346e292bb9a40f9a43e364ebdf387bb909
parentecfc3ba4143115d03622dc947cd7bbf834f76f23 (diff)
Catch StopIteration in a generator and return instead, per PEP 479
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
-rw-r--r--blist/_sortedlist.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/blist/_sortedlist.py b/blist/_sortedlist.py
index b34f69e..1f77170 100644
--- a/blist/_sortedlist.py
+++ b/blist/_sortedlist.py
@@ -420,11 +420,14 @@ class _setmixin(object):
def __iter__(self):
it = super(_setmixin, self).__iter__()
while True:
- item = next(it)
- n = len(self)
- yield item
- if n != len(self):
- raise RuntimeError('Set changed size during iteration')
+ try:
+ item = next(it)
+ n = len(self)
+ yield item
+ if n != len(self):
+ raise RuntimeError('Set changed size during iteration')
+ except StopIteration:
+ return
def safe_cmp(f):
def g(self, other):