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
PEP479 changed generator StopIteration behavior, so now putting
@profile
on a generator looks like this: