You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In /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
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 with return will do the trick.
Reacted by Derek Watson, Tales da Aparecida, Christopher Bare and Zhongshuai
def pattern_stopiteration_workaround():
try:
print(lexeme('gave'))
except:
pass
def main():
pattern_stopiteration_workaround()
#Add your other code here
Basically, the pattern code will fail the first time you run it, so you first need to run it once and catch the Exception it throws.
It's worked well enough for my own scripts, but I don't know if it fixes every possible issue.
Ideally though, somebody should fork the clips/pattern project since it's no longer maintained.
def pattern_stopiteration_workaround():
try:
print(lexeme('gave'))
except:
pass
def main():
pattern_stopiteration_workaround()
#Add your other code here
Basically, the pattern code will fail the first time you run it, so you first need to run it once and catch the Exception it throws.
It's worked well enough for my own scripts, but I don't know if it fixes every possible issue.
Ideally though, somebody should fork the clips/pattern project since it's no longer maintained.
If you use this method you should do 'except RuntimeError', in case you get any other error instead.
Activity
paulsantolla commentedon Oct 9, 2018
Experiencing the same issue. Works the second+ time it is used for some reason.

paulsantolla commentedon Oct 9, 2018
Soo.. since it only fails the first time... One can throw a hack into files to get it to work. Here's a quick & dirty fix until this is resolved:
agodbehere commentedon Oct 16, 2018
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 StopIterationwithreturnwill do the trick.replace StopIteration with return
replace StopIteration with return
Raphencoder commentedon Feb 25, 2019
Same here on python 3.7, any update planned?
Raysmond commentedon Apr 28, 2019
Try this,
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.6.8
It didn't work with Python 3.7. Python 3.6 works for me.
magnusja commentedon Jun 28, 2019
This is incredibly annoying when parallelizing with joblib ...
Pikamander2 commentedon May 15, 2021
Here's an easy workaround:
Basically, the pattern code will fail the first time you run it, so you first need to run it once and catch the Exception it throws.
It's worked well enough for my own scripts, but I don't know if it fixes every possible issue.
Ideally though, somebody should fork the clips/pattern project since it's no longer maintained.
nershman commentedon Jul 10, 2021
If you use this method you should do 'except RuntimeError', in case you get any other error instead.