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 locations of with statement's cleanup instructions #120763

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jun 19, 2024


# Expect three load None instructions for the no-exception __exit__ call,
# and one RETURN_VALUE.
# They should all have the locations of the context manager ('xyz').
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't the RETURN_VALUE have the location of the return statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calculation of the value has that location. The return itself occurs after the exit, so it gets the location of the exit (the last instruction executed before the return).

@iritkatriel iritkatriel merged commit 55596ae into python:main Jun 20, 2024
41 checks passed
@miss-islington-app
Copy link

Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 20, 2024
pythonGH-120763)

(cherry picked from commit 55596ae)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
pythongh-98442: fix location of with statement's cleanup instructions
@bedevere-app
Copy link

bedevere-app bot commented Jun 20, 2024

GH-120786 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 20, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 20, 2024
pythonGH-120763)

(cherry picked from commit 55596ae)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
pythongh-98442: fix location of with statement's cleanup instructions
@bedevere-app
Copy link

bedevere-app bot commented Jun 20, 2024

GH-120787 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jun 20, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
iritkatriel added a commit that referenced this pull request Sep 2, 2024
…ns (GH-120763) (#120786)

gh-98442: fix locations of with statement's cleanup instructions (GH-120763)
(cherry picked from commit 55596ae)


gh-98442: fix location of with statement's cleanup instructions

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
iritkatriel added a commit that referenced this pull request Sep 15, 2024
…ns (GH-120763) (#120787)

gh-98442: fix locations of with statement's cleanup instructions (GH-120763)
(cherry picked from commit 55596ae)


gh-98442: fix location of with statement's cleanup instructions

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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