``` 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)]) ``` Output: ``` [((1, 1, 0, 0), 'RESUME', 0), ((2, 2, 6, 7), 'LOAD_GLOBAL', 'x'), ((2, 3, 1, 12), 'BEFORE_WITH', None), ((2, 3, 1, 12), 'POP_TOP', None), ((3, 3, 10, 12), 'NOP', None), ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'CALL', 2), ((2, 3, 1, 12), 'POP_TOP', None), ((2, 3, 1, 12), 'LOAD_CONST', 42), <-- incorrect ((2, 3, 1, 12), 'RETURN_VALUE', None), <-- incorrect ((2, 3, 1, 12), 'PUSH_EXC_INFO', None), ((2, 3, 1, 12), 'WITH_EXCEPT_START', None), ((2, 3, 1, 12), 'POP_JUMP_IF_TRUE', 50), ((2, 3, 1, 12), 'RERAISE', 2), ((2, 3, 1, 12), 'POP_TOP', None), ((2, 3, 1, 12), 'POP_EXCEPT', None), ((2, 3, 1, 12), 'POP_TOP', None), ((2, 3, 1, 12), 'POP_TOP', None), ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'RETURN_VALUE', None), ((None, None, None, None), 'COPY', 3), ((None, None, None, None), 'POP_EXCEPT', None), ((None, None, None, None), 'RERAISE', 1)] ``` <!-- gh-linked-prs --> ### Linked PRs * gh-120763 * gh-120786 * gh-120787 <!-- /gh-linked-prs -->