Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Python 3.7 StopIteration exception #152

Open
Zannick opened this issue Apr 7, 2019 · 0 comments · May be fixed by #153
Open

Python 3.7 StopIteration exception #152

Zannick opened this issue Apr 7, 2019 · 0 comments · May be fixed by #153

Comments

@Zannick
Copy link

Zannick commented Apr 7, 2019

PEP479 changed generator StopIteration behavior, so now putting @profile on a generator looks like this:

@profile
def iter_foo(a):
    for i in range(a):
        yield i

for i in iter_foo(5):
    print(i)
Traceback (most recent call last):
  File ".../line_profiler.py", line 102 in wrapper
    item = g.send(input)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ".../kernprof", line 11, in <module>
    load_entry_point('line-profiler==2.1.1', 'console_scripts', 'kernprof')()
  File ".../kernprof.py", line 222, in main
    execfile(script_file, ns, ns)
  File ".../kernprof.py", line 35, in execfile
    exec_(compile(f.read(), filename, 'exec'), globals, locals)
  File ".../tmp.py", line 6, in <module>
    for i in iter_foo(5):
RuntimeError: generator raised StopIteration
@Hanaasagi Hanaasagi linked a pull request Apr 17, 2019 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant