LOAD_GLOBAL instruction with wrong source position · Issue #91409 · python/cpython (original) (raw)
@terryjreedy The problem seems is be back in 3.11.0b4 (on ubuntu)
import dis
dix = 5
def f(): dis.b() # wrong source range dix.b() # correct source range
d = [bc for bc in dis.Bytecode(f) if bc.opname == "LOAD_GLOBAL"]
print(d)
assert len(d) == 2
LOAD_GLOBAL has a wrong end column if the global value is an imported module
assert d[0].positions[2:] == d[1].positions[2:] == (4, 7)
output:
[Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='dis', argrepr='NULL + dis', offset=2, starts_line=7, is_jump_target=False, positions=Positions(lineno=7, end_lineno=7, col_offset=4, end_col_offset=9))
, Instruction(opname='LOAD_GLOBAL', opcode=116, arg=4, argval='dix', argrepr='dix', offset=40, starts_line=8, is_jump_target=False, positions=Positions(lineno=8, end_lineno=8, col_offset=4, end_col_offset=7))]
Traceback (most recent call last):
File "/home/frank/projects/executing/test2.py", line 18, in <module>
assert d[0].positions[2:] == d[1].positions[2:] == (4, 7)
AssertionError
can we open this issue again?