Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #26466: Fix some Deprecation warning for generator ...
Browse files Browse the repository at this point in the history
... raising StopIteration
  • Loading branch information
Vincent Klein committed Oct 11, 2018
1 parent 90e1749 commit 9da555b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/sage/categories/sets_cat.py
Expand Up @@ -2165,7 +2165,10 @@ def __iter__(self):
# visualize an odometer, with "wheels" displaying "digits"...:
factors = list(self.cartesian_factors())
wheels = [iter(f) for f in factors]
digits = [next(it) for it in wheels]
try:
digits = [next(it) for it in wheels]
except StopIteration:
return
while True:
yield self._cartesian_product_of_elements(digits)
for i in range(len(digits)-1, -1, -1):
Expand All @@ -2174,7 +2177,10 @@ def __iter__(self):
break
except StopIteration:
wheels[i] = iter(factors[i])
digits[i] = next(wheels[i])
try:
digits[i] = next(wheels[i])
except StopIteration:
return
else:
break

Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/finite_state_machine.py
Expand Up @@ -13701,8 +13701,8 @@ def compare_to_tape(self, track_number, word):
it_word = iter(word)

# check letters in cache
if any(letter_on_track != next(it_word)
for letter_on_track in track_cache):
if any(letter_on_track != letter_in_word
for letter_on_track, letter_in_word in zip(track_cache, it_word)):
return False

# check letters not already cached
Expand Down

0 comments on commit 9da555b

Please sign in to comment.