Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
def f(): with x: return 42import disfrom pprint import pprint as ppdef 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)]