Skip to content

Incorrect oparg check in COMPARE_OP_INT specialization #141836

@chrooti

Description

@chrooti

Bug report

Bug description:

COMPARE_OP is "documented" to use oparg >> 5 to choose which comparison operation to execute. However in COMPARE_OP_INT and other specializations oparg without any shifting is used.

I'm not entirely sure if this is a bug because:

  • i hit while writing a "convert X to python bytecode" tool and my python bytecode knowledge is not that good
  • by checking empirically instruction that are emitted by CPython are encoded to work correctly with this quirk (i.e. COMPARE_OP is generally emitted with an argument that has one of the 4 low bits set)

I'm probably missing something, but I'm still reporting it just in case.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

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