diff --git a/src/sage/numerical/linear_functions.pyx b/src/sage/numerical/linear_functions.pyx index 5549ff436f5..f3fc6fe419c 100644 --- a/src/sage/numerical/linear_functions.pyx +++ b/src/sage/numerical/linear_functions.pyx @@ -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): """ @@ -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"""