StopIteration raised every time
See original GitHub issueIn /text/init.py StopIteration gets raised every time
def _read(path, encoding="utf-8", comment=";;;"):
""" Returns an iterator over the lines in the file at the given path,
strippping comments and decoding each line to Unicode.
"""
if path:
if isinstance(path, str) and os.path.exists(path):
# From file path.
f = open(path, "r", encoding="utf-8")
elif isinstance(path, str):
# From string.
f = path.splitlines()
else:
# From file or buffer.
f = path
for i, line in enumerate(f):
line = line.strip(BOM_UTF8) if i == 0 and isinstance(line, str) else line
line = line.strip()
line = decode_utf8(line, encoding)
if not line or (comment and line.startswith(comment)):
continue
yield line
raise StopIteration
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8
Top Results From Across the Web
generator raised StopIteration" every time I try to run app ...
Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator's useful life (the exception was ...
Read more >PEP 479 – Change StopIteration handling inside generators
This PEP proposes a change to generators: when StopIteration is raised inside a generator, ... Each time it is (re)started, it may either...
Read more >Complete Guide to Python StopIteration - eduCBA
When the specified number of iterations are done, StopIteration is raised by the next method in case of iterators and generators (works similar...
Read more >"RuntimeError: generator raised StopIteration" every time I try ...
PYTHON : "RuntimeError: generator raised StopIteration " every time I try to run app [ Gift : Animated Search Engine ...
Read more >3. Generators and Iterators | Advanced - Python Courses eu
Calling 'next' for the first time: Python Beginner Calling 'next' for ... Let's have a look at a generator in which we raise...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is likely due to PEP-479 (https://www.python.org/dev/peps/pep-0479/)
This introduced a breaking change in the handling of “StopIteration” in generators that was activated by default in Python 3.7. In Python3.6, you would have seen a warning about the upcoming deprecation.
Someone should refer to PEP-479, in particular this section (https://www.python.org/dev/peps/pep-0479/#id38) to refactor this code. At first glance, I would bet that replacing
raise StopIteration
withreturn
will do the trick.Same here on python 3.7, any update planned?