Open NicolasBizzozzero opened 4 years ago
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: https://github.com/RaRe-Technologies/gensim/issues/2438).
This PR fixes the _read generator by removing the StopIteration exception raised in it. It solves the following issues :