Bug report
Bug description:
From https://docs.python.org/3.12/library/dis.html#opcode-COMPARE_OP,
dis.cmp_op should be able lookup the comparison operation string from the opcode's argument.
However, in Python 3.12.2 and 3.13.0a5, this fails with "IndexError: tuple index out of range"
import dis
def my_fun(a, b):
return a <= b
for instruction in dis.get_instructions(my_fun):
if instruction.opname == 'COMPARE_OP':
print(dis.cmp_op[instruction.arg])
In Python 3.11.8, it prints "<=" as expected.
dis.dis output of my_fun in Python 3.12.2:
1 0 RESUME 0
2 2 LOAD_FAST 0 (a)
4 LOAD_FAST 1 (b)
6 COMPARE_OP 26 (<=)
10 RETURN_VALUE
dis.cmp_op in Python 3.12.2:
('<', '<=', '==', '!=', '>', '>=')
Workaround: use instruction.argrepr.
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
From https://docs.python.org/3.12/library/dis.html#opcode-COMPARE_OP,
dis.cmp_opshould be able lookup the comparison operation string from the opcode's argument.However, in Python 3.12.2 and 3.13.0a5, this fails with "IndexError: tuple index out of range"
In Python 3.11.8, it prints "<=" as expected.
dis.disoutput ofmy_funin Python 3.12.2:dis.cmp_opin Python 3.12.2:Workaround: use
instruction.argrepr.CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Linked PRs