You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Source location of return instruction in a with block is incorrect #98442
def f():
with x:
return 42
import dis
from pprint import pprint as pp
def pos(p):
return (p.lineno, p.end_lineno, p.col_offset, p.end_col_offset)
pp([(pos(x.positions), x.opname, x.argval) for x in dis.get_instructions(f)])
changed the title [-]location of return instruction in a with block is incorrect[/-][+]Source locations of return instruction in a with block is incorrect[/+]on Oct 19, 2022
changed the title [-]Source locations of return instruction in a with block is incorrect[/-][+]Source location of return instruction in a with block is incorrect[/+]on Oct 19, 2022
Activity
pythongh-98442: Fix location info of return statement
[-]location of return instruction in a with block is incorrect[/-][+]Source locations of return instruction in a with block is incorrect[/+][-]Source locations of return instruction in a with block is incorrect[/-][+]Source location of return instruction in a with block is incorrect[/+]iritkatriel commentedon Oct 19, 2022
@nedbat FYI.
iritkatriel commentedon Jun 19, 2024
This is now less wrong, but still there are instructions (in the
__exit__call) that span the whole body of the with-block:The return instruction takes its location from there, so it will be fixed once this is.
pythongh-98442: fix location of with statement's cleanup instructions
iritkatriel commentedon Jun 19, 2024
With the fix in the PR we get:
gh-98442: fix locations of with statement's cleanup instructions (#12…
pythongh-98442: fix locations of with statement's cleanup instructions (
pythongh-98442: fix locations of with statement's cleanup instructions (
pythongh-98442: fix locations of with statement's cleanup instructions (
pythongh-98442: fix locations of with statement's cleanup instructions (
pythongh-98442: fix locations of with statement's cleanup instructions (
[3.13] gh-98442: fix locations of with statement's cleanup instructio…
[3.12] gh-98442: fix locations of with statement's cleanup instructio…