Closed as not planned
Description
Bug report
Bug description:
The following code reproduces the bug:
import dis
code = """
not a == b
"""
code = compile(code, "<code>", "exec")
for bc in dis.get_instructions(code):
p = bc.positions
print(
f"{p.lineno}:{p.col_offset} {p.end_lineno}:{p.end_col_offset}",
bc.opname,
bc.argval,
)
for bc in dis.get_instructions(code):
if bc.opname == "COMPARE_OP":
assert bc.positions.col_offset == 4
output (Python 3.13.0a3+):
0:0 1:0 RESUME 0
2:4 2:5 LOAD_NAME a
2:9 2:10 LOAD_NAME b
2:0 2:10 COMPARE_OP == # <-- incorrect col_offset
2:0 2:10 UNARY_NOT None
2:0 2:10 POP_TOP None
2:0 2:10 RETURN_CONST None
Traceback (most recent call last):
File "/home/frank/projects/executing/codi.py", line 20, in <module>
assert bc.positions.col_offset == 4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
The source range for the compare operation should not include the not
.
There was no problem in 3.12, where the col_offset started at 4
output (Python 3.12.1):
0:0 1:0 RESUME 0
2:4 2:5 LOAD_NAME a
2:9 2:10 LOAD_NAME b
2:4 2:10 COMPARE_OP == # <-- correct col_offset
2:0 2:10 UNARY_NOT None
2:0 2:10 POP_TOP None
2:0 2:10 RETURN_CONST None
I bisected the problem down to 7b2d94d (@brandtbucher).
The problem can also be reproduced on the current main (7a47054).
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux