Skip to content

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

Closed

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

Activity

  1. added
    type-bug
    on Aug 12, 2025
  2. added
    interpreter-core
    on Aug 12, 2025
  3. added a commit that references this issue on Aug 13, 2025
  4. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-coretype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions