-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change StopIteration to return in generators
Python 3.7 changed the way generators work. Code like this: ``` def gen(): yield 'a' yield 'b' raise StopIteration for i in gen(): print(i) ``` causes an exception in python 3.7: ``` (py3) root@f36c5a2313f9:/wbia/wildbook-ia# python3.6 /tmp/test_generator.py a b (py3) root@f36c5a2313f9:/wbia/wildbook-ia# python3.7 /tmp/test_generator.py a b Traceback (most recent call last): File "/tmp/test_generator.py", line 4, in gen raise StopIteration() StopIteration The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/tmp/test_generator.py", line 6, in <module> for i in gen(): RuntimeError: generator raised StopIteration ``` It can be fixed by doing `return` instead of `raise StopIteration`.
- Loading branch information
1 parent
4822ce2
commit 94e59a3
Showing
4 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters