pattern
pattern copied to clipboard
StopIteration raised every time
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
Experiencing the same issue. Works the second+ time it is used for some reason.

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:

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 with return will do the trick.
Same here on python 3.7, any update planned?
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.
This is incredibly annoying when parallelizing with joblib ...
Here's an easy workaround:
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.
Here's an easy workaround:
def pattern_stopiteration_workaround(): try: print(lexeme('gave')) except: pass def main(): pattern_stopiteration_workaround() #Add your other code hereBasically, 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.