From 4fefac11c6fda6e0bc3cb9b8e84bf862e31ce5e4 Mon Sep 17 00:00:00 2001 From: Yutao Yuan Date: Mon, 7 Aug 2023 23:53:14 +0800 Subject: [PATCH] avoid StopIteration in generators --- src/sage/numerical/linear_functions.pyx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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"""