Skip to content

Commit 6820d2a

Browse files
committed
avoid StopIteration in generators
1 parent 9660827 commit 6820d2a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sage/numerical/linear_functions.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,10 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
15791579
while True:
15801580
yield (lhs, rhs)
15811581
lhs = rhs
1582-
rhs = next(term_iter)
1582+
try:
1583+
rhs = next(term_iter)
1584+
except StopIteration:
1585+
return
15831586

15841587
def inequalities(self):
15851588
"""
@@ -1612,7 +1615,10 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
16121615
while True:
16131616
yield (lhs, rhs)
16141617
lhs = rhs
1615-
rhs = next(term_iter)
1618+
try:
1619+
rhs = next(term_iter)
1620+
except StopIteration:
1621+
return
16161622

16171623
def _repr_(self):
16181624
r"""

0 commit comments

Comments
 (0)