Skip to content

Bytecode compatibility - Exception-Handling Bytecode Stack Sequence Mismatch #19

@youknowone

Description

@youknowone

Summary

Background:
compare_bytecode.report shows high-frequency mismatches in exception control flow,
especially around COPY/POP_EXCEPT/RERAISE/RETURN_VALUE transitions. This indicates
instability in CPython 3.14-compatible exception-frame sequencing.

Task:

  • Align RustPython bytecode emission for exception-sensitive paths (try/except/finally,
    with, raise/re-raise).
  • Verify sequencing for instruction pairs:
    • COPY -> POP_EXCEPT
    • POP_EXCEPT -> RERAISE
    • RETURN_VALUE / RERAISE / COPY interaction in exception epilogues.
  • Compare outputs against CPython at parser/codegen level and adjust stack effect
    handling if needed.

Acceptance criteria:

  • Top bytecode diff pair counts for exception-related instructions drop significantly.
  • test_traceback, traceback, inspect, pydoc no longer show broad control-flow
    mismatch in repeated patterns.
  • No new CPython/RustPython crashes in basic exception-heavy test cases.

Details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions