“RuntimeError: generator raised StopIteration” every time I try to run app

To judge from the file paths, it looks like you’re running Python 3.7. If so, you’re getting caught by new-in-3.7 behavior:

PEP 479 is enabled for all code in Python 3.7, meaning that StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. (Contributed by Yury Selivanov in bpo-32670.)

Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator’s useful life (the exception was silently swallowed). The module you’re using will have to be recoded to work as intended with 3.7.

Chances are they’ll need to change:

yield next(seq)

to:

try:
    yield next(seq)
except StopIteration:
    return

Leave a Comment