◐ Shell
clean mode source ↗

Remove JUMP_IF_NOT_EXC_MATCH, SET_EXC_INFO by youknowone · Pull Request #6820 · RustPython/RustPython

📝 Walkthrough

Walkthrough

This PR refactors exception handling bytecode by removing JumpIfNotExcMatch and SetExcInfo opcodes. Exception matching logic is consolidated into CheckExcMatch, which now sets the matched exception as current, while PopJumpIfFalse replaces JumpIfNotExcMatch for conditional jumps. The bytecode instruction enum and related dispatch paths are simplified accordingly.

Changes

Cohort / File(s) Summary
Instruction variants removal
crates/compiler-core/src/bytecode/instruction.rs
Removed public enum variants JumpIfNotExcMatch(Arg<Label>) and SetExcInfo from Instruction. Removed their handling from TryFrom<u8>, InstructionMetadata (label_arg, stack_effect, fmt_dis), and formatting/disassembly paths.
Code generation updates
crates/codegen/src/compile.rs
Replaced duplicated exception-copy sequence with inline CheckExcMatch and PopJumpIfFalse for per-handler exception matching. Removed SetExcInfo emission since CheckExcMatch now sets the matched exception as current.
VM execution logic
crates/vm/src/frame.rs
Removed implementations of Instruction::JumpIfNotExcMatch and Instruction::SetExcInfo. Enhanced CheckExcMatch with BaseException inheritance validation. Updated CHECK_EG_MATCH to set VM's current exception to matched exception after exception_group_match.
Opcode classification
crates/stdlib/src/opcode.rs
Removed JumpIfNotExcMatch from has_jump() match arms, narrowing the set of jump-classified instructions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ShaharNaveh

Poem

🐰 With CheckExcMatch we hop more true,
SetExcInfo and JumpIfNot—adieu!
PopJumpIfFalse now bears the load,
Exception paths on cleaner road! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main change: removal of two instruction variants (JUMP_IF_NOT_EXC_MATCH and SET_EXC_INFO) from the codebase, which is clearly reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.