Skip to content

Commit

Permalink
avoid StopIteration in generators
Browse files Browse the repository at this point in the history
  • Loading branch information
infmagic2047 committed Aug 7, 2023
1 parent 5afb200 commit 4fefac1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sage/numerical/linear_functions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,10 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
while True:
yield (lhs, rhs)
lhs = rhs
rhs = next(term_iter)
try:
rhs = next(term_iter)
except StopIteration:
return

def inequalities(self):
"""
Expand Down Expand Up @@ -1612,7 +1615,10 @@ cdef class LinearConstraint(LinearFunctionOrConstraint):
while True:
yield (lhs, rhs)
lhs = rhs
rhs = next(term_iter)
try:
rhs = next(term_iter)
except StopIteration:
return

def _repr_(self):
r"""
Expand Down

0 comments on commit 4fefac1

Please sign in to comment.