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

Python 3.7 StopIteration exception #152

@Zannick

Description

@Zannick

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions