Skip to content

flow-graph fails to re-initialize removed instructions to 0 resulting in re-used exception handler #137681

@DinoV

Description

@DinoV

Bug report

Bug description:

# pyre-ignore-all-errors
def foo():
    try:
        [x for x in abc]
    except OSError:
        pass

    return
import dis
dis.dis(foo)

When this code gets compiled a NOT_TAKEN instruction gets inserted after the exception handler pass has run and no except handler block is added to it. But it re-uses an instruction that got NOP'd out and previously had an instruction handler associated with it. The end result is that the NOT_TAKEN has a rather random exception handler block associated with it.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions