amyreese / fissix

backport of lib2to3, with enhancements
Other
46 stars 24 forks source link

catch StopIteration around 1-arg next in generator functions #33

Open graingert opened 3 years ago

graingert commented 3 years ago

Description

catch StopIteration around 1-arg next in generator functions

example from https://www.python.org/dev/peps/pep-0479/#converting-the-exception-inside-next

input:

def my_generator():
    ...
    yield next(it)
    ...

expected output:

def my_generator():
    try:
        ...
        yield next(it)
        ...
    except StopIteration
        return

Details