#26458 closed enhancement (fixed)
Py3: Fix DeprecationWarning: generator X raised StopIteration for combinat/words
Reported by: | vklein | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.5 |
Component: | python3 | Keywords: | |
Cc: | embray, slabbe | Merged in: | |
Authors: | Vincent Klein | Reviewers: | Frédéric Chapoton |
Report Upstream: | N/A | Work issues: | |
Branch: | f28b724 (Commits) | Commit: | f28b724d8974fedceda2fccf79d4569ab34d2f3a |
Dependencies: | Stopgaps: |
Description
Change History (9)
comment:1 Changed 5 months ago by
- Branch set to u/vklein/py3__fix_deprecationwarning__generator_x_raised_stopiteration_for_combinat_words
comment:2 Changed 5 months ago by
- Commit set to f28b724d8974fedceda2fccf79d4569ab34d2f3a
comment:3 Changed 5 months ago by
- Status changed from new to needs_review
comment:4 Changed 4 months ago by
- Cc embray added
This is working, but I am not convinced at all that this is the right way to do that. @embray, any opinion ?
comment:5 Changed 4 months ago by
I agree try: ... except StopIteration
are sort of ugly, i use them when i don't find more concise ways to do that.
That being said this syntax is consistent with pep-0479
comment:6 Changed 4 months ago by
I have a way to avoid try except
for abstract_word.py
diff --git a/src/sage/combinat/words/abstract_word.py b/src/sage/combinat/words/abstract_word.py index 3e36111..16fa382 100644 --- a/src/sage/combinat/words/abstract_word.py +++ b/src/sage/combinat/words/abstract_word.py @@ -1370,16 +1370,17 @@ class Word_class(SageObject): ... TypeError: mod(=a) must be None or an integer """ + if self.is_empty() + return + if mod in (None, 0): i = iter(self) j = iter(self) + next(j) - try: - next(j) - while True: - yield next(j) - next(i) - except StopIteration: - return + for a, b in zip(i,j): + yield a -b + return elif mod in ZZ: Zn = Integers(mod)
Tell me what you prefer.
comment:7 Changed 4 months ago by
- Cc slabbe added
- Reviewers set to Frédéric Chapoton
- Status changed from needs_review to positive_review
ok, let it be.
comment:8 Changed 4 months ago by
- Branch changed from u/vklein/py3__fix_deprecationwarning__generator_x_raised_stopiteration_for_combinat_words to f28b724d8974fedceda2fccf79d4569ab34d2f3a
- Resolution set to fixed
- Status changed from positive_review to closed
comment:9 Changed 4 months ago by
- Milestone changed from sage-8.4 to sage-8.5
This should be re-targeted for 8.5.
Note: See
TracTickets for help on using
tickets.
New commits:
Trac #26458: Py3 combinat/words fix deprecation warning ...