Skip to content

Commit bfd17cc

Browse files
committed
handle StopIteration in lazy_list_from_function
1 parent 33eb23e commit bfd17cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sage/misc/lazy_list.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,11 @@ cdef class lazy_list_from_function(lazy_list_generic):
10591059
step 1
10601060
"""
10611061
while len(self.cache) <= i:
1062-
self.cache.append(self.callable(len(self.cache)))
1062+
try:
1063+
value = self.callable(len(self.cache))
1064+
except StopIteration:
1065+
return 1
1066+
self.cache.append(value)
10631067

10641068
def __reduce__(self):
10651069
r"""

0 commit comments

Comments
 (0)