aboutsummaryrefslogtreecommitdiff
path: root/blist-stopiteration.patch
blob: 198bef4cfb7aca9cdb4187e8862ebc18eeffd4bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Sun, 8 Jul 2018 09:00:16 +0200
Subject: Catch StopIteration in a generator and return instead, per PEP 479

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>

Forwarded: https://github.com/DanielStutzbach/blist/pull/92
Bug-Debian: https://bugs.debian.org/902757
---
 blist/_sortedlist.py | 13 ++++++++-----
 1 file 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):