Skip to content

Source locations in 'assert' bytecode are incorrect #98398

Closed
@iritkatriel

Description

@iritkatriel
def f(): a,bb,ccc = 1,2,3 assert (a > 0 and bb > 0 and ccc == 4) 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 is:

[((1, 1, 0, 0), 'RESUME', 0), ((2, 2, 12, 17), 'LOAD_CONST', (1, 2, 3)), ((2, 2, 1, 9), 'UNPACK_SEQUENCE', 3), ((2, 2, 1, 2), 'STORE_FAST', 'a'), ((2, 2, 3, 5), 'STORE_FAST', 'bb'), ((2, 2, 6, 9), 'STORE_FAST', 'ccc'), ((3, 3, 9, 10), 'LOAD_FAST', 'a'), ((3, 3, 13, 14), 'LOAD_CONST', 0), ((3, 3, 9, 14), 'COMPARE_OP', '>'), ((3, 3, 9, 14), 'POP_JUMP_IF_FALSE', 50), ((4, 4, 9, 11), 'LOAD_FAST', 'bb'), ((4, 4, 14, 15), 'LOAD_CONST', 0), ((4, 4, 9, 15), 'COMPARE_OP', '>'), ((4, 4, 9, 15), 'POP_JUMP_IF_FALSE', 50), ((5, 5, 9, 12), 'LOAD_FAST', 'ccc'), ((5, 5, 16, 17), 'LOAD_CONST', 4), ((5, 5, 9, 17), 'COMPARE_OP', '=='), ((5, 5, 9, 17), 'POP_JUMP_IF_TRUE', 54), ((5, 5, 9, 17), 'LOAD_ASSERTION_ERROR', None), <--- incorrect ((5, 5, 9, 17), 'RAISE_VARARGS', 1), <--- incorrect ((5, 5, 9, 17), 'LOAD_CONST', None), ((5, 5, 9, 17), 'RETURN_VALUE', None)] 

Metadata

Metadata

Assignees

Labels

3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions