-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect stack traces when re-entering a generator/coroutine stack via .throw() #73776
Comments
The attached script sets up a stack of generators calling each other via 'yield from': f yields from g yield from h. Then the generator at the bottom of the stack yields. Before they yield, sys._getframe shows the expected stack (or if you put in traceback.print_stack() you get the same thing). After they yield, it depends: if the generator is resumed via 'gen.send(None)', then the stack looks sensible. But if the generator is resumed via 'gen.throw(...)', then the stack is weird: Objects/genobject.c:_gen_throw implements 'yield from' in an weird manual way, where it first directly resumes the innermost generator frame, and then propagates any result to the next generator frame, etc. So the output I get from the sample script is: ~$ python3.6 weird-throw-stack.py This causes problems for stack-based profiling (vmprof/vmprof-python#117), debuggers, and other tools that need to introspect the stack. |
I proposed a PR to fix this: #19896 |
I just filed a related issue to this that's also similar to bpo-29587: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: