Skip to content

IndexError when accessing dis.cmp_op[instruction.arg] in Python 3.13 but not in 3.10 #131501

@mouchen626

Description

@mouchen626

Bug report

Bug description:

The following code, which works without error in Python 3.10, raises an IndexError in Python 3.13 when trying to access dis.cmp_op[instruction.arg]:

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])

CPython versions tested on:

3.13

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions