Skip to content
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

gh-98442: Fix source location of return in a with block #98443

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Oct 19, 2022

@iritkatriel iritkatriel changed the title gh-98442: Fix location info of return in a with block gh-98442: Fix source location of return in a with block Oct 19, 2022
@iritkatriel iritkatriel marked this pull request as draft October 19, 2022 14:36
@markshannon
Copy link
Member

This looks like it ought to be correct. PEP 626 says that return should be traced, so the RETURN_VALUE should have the location of the return statement.

@iritkatriel
Copy link
Member Author

This looks like it ought to be correct. PEP 626 says that return should be traced, so the RETURN_VALUE should have the location of the return statement.

Do you mean that the current output is correct? It shows the whole with-block as the location of the RETURN_VALUE.

@iritkatriel
Copy link
Member Author

iritkatriel commented Jun 13, 2024

This issue seems to have been created semi-deliberately here: https://github.com/python/cpython/pull/26513/files#diff-ebc983d9f91e5bcf73500e377ac65e85863c4f77fd5b6b6caf4fcdf7c0f0b057L1868

The location of the return AST node is overwritten in the compiler_unwind_fblock function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source location of return instruction in a with block is incorrect
3 participants