-
- Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
This is a particular case of #93691.
This code:
def f(): a, b, e, f = 1,2,3,4 if (a or (b and e) or f): 12 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)])
Outputs:
[((1, 1, 0, 0), 'RESUME', 0), ((2, 2, 14, 21), 'LOAD_CONST', (1, 2, 3, 4)), ((2, 2, 1, 11), 'UNPACK_SEQUENCE', 4), ((2, 2, 1, 2), 'STORE_FAST', 'a'), ((2, 2, 4, 5), 'STORE_FAST', 'b'), ((2, 2, 7, 8), 'STORE_FAST', 'e'), ((2, 2, 10, 11), 'STORE_FAST', 'f'), ((3, 3, 5, 6), 'LOAD_FAST', 'a'), ((3, 6, 1, 5), 'POP_JUMP_IF_TRUE', 32), <--- ((4, 4, 5, 6), 'LOAD_FAST', 'b'), ((3, 6, 1, 5), 'POP_JUMP_IF_FALSE', 28), <--- ((4, 4, 11, 12), 'LOAD_FAST', 'e'), ((3, 6, 1, 5), 'POP_JUMP_IF_TRUE', 32), <--- ((5, 5, 4, 5), 'LOAD_FAST', 'f'), ((3, 6, 1, 5), 'POP_JUMP_IF_FALSE', 36), <--- ((6, 6, 3, 5), 'LOAD_CONST', None), ((6, 6, 3, 5), 'RETURN_VALUE', None), ((3, 6, 1, 5), 'LOAD_CONST', None), ((3, 6, 1, 5), 'RETURN_VALUE', None)]
The marked jumps have very wide locations - spanning the whole conditional expression. They should instead point to the particular sub-expression that they come from.
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error