Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStopIteration & RuntimeError fix for Python >= 3.7 #294
Conversation
StopIteration & RuntimeError fix for Python >= 3.7
|
Thank you for all the work @NicolasBizzozzero ! Seems like the CI build is based on python=3.6 and causing the check failures? Who can help to fix this issue as it seems stupid to not able to fix this for quite a while... |
|
Meanwhile you can monkey patch around this issue by calling this method in your module: def patch_pattern():
from pattern import text
original_read = text._read
@functools.wraps(original_read)
def patched_read(*args, **kwargs):
try:
for r in original_read(*args, **kwargs):
yield r
except RuntimeError:
pass
text._read = patched_read |
Since Python 3.7, all StopIteration exceptions raised inside a generator are transformed into RuntimeError (see PEP-0479 and this answer from StackOverflow). This new behavior made pattern unusable for all Python3.7+ users and all packages depending on it (gensim for instance: RaRe-Technologies/gensim#2438).
This PR fixes the _read generator by removing the StopIteration exception raised in it. It solves the following issues :