◐ Shell
clean mode source ↗

Fix opcode args by ShaharNaveh · Pull Request #6649 · RustPython/RustPython

📝 Walkthrough

Walkthrough

The opcode module's validity checks are simplified to rely on a unified validation approach, while expanding the set of recognized instructions in has_name and has_jump. Error handling for invalid stack arguments is improved with detailed type information, and boolean extraction is standardized.

Changes

Cohort / File(s) Change Summary
Opcode Validation & Instruction Set Expansion
crates/stdlib/src/opcode.rs
Refactored has_const, has_name, has_jump, has_free, and has_local to use unified Self::is_valid(opcode) checks. Expanded has_name to include ImportName, LoadAttr, LoadMethod, LoadNameAny, and StoreLocal. Expanded has_jump to cover JumpIfNotExcMatch, JumpIfTrueOrPop, and additional jump-like instructions. Improved stack_effect error handling to return detailed type error messages for non-integer oparg values. Replaced pattern-based boolean extraction with v.try_to_bool(vm). Removed unused PyBool and PyNone imports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through opcodes clean,
Where jumps and names now widely seen,
With errors clear and checks so tight,
The code simplifies—what a sight!
No more redundant paths to chase,
Just unified validation's grace!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix opcode args' is vague and does not clearly convey what specific issue is being fixed or what the main change accomplishes. Use a more descriptive title that explains the specific fix, such as 'Refactor opcode validation and improve stack effect error handling' or 'Simplify opcode checks and enhance type error messages'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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.