◐ Shell
clean mode source ↗

`init` debug helper by youknowone · Pull Request #6315 · RustPython/RustPython

Walkthrough

Adds debug-only diagnostics to downcast/init error paths in two VM modules: captures class names, inspects error messages for duplicate class occurrences, and augments/panics with a suggestion about types that may not support init or subclassing.

Changes

Cohort / File(s) Summary
Debug error diagnostics
crates/vm/src/types/slot.rs
In Initializer::slot_init, capture the class name when Zelf downcast fails; in debug builds, reprint the error, check for the class name appearing twice, and panic with a message suggesting the type may not support init (prompting to override slot_init) when detected. Adds a non-functional safety comment in __init__.
Enhanced downcast error messages
crates/vm/src/vm/vm_new.rs
In debug assertion path for downcast errors where actual and expected class match, prefix the existing reminder about #[pyclass(with(Constructor))]? with an additional note suggesting the type may not support subclassing well. Only the diagnostic text changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Inspect debug-only conditional and panic condition in crates/vm/src/types/slot.rs.
  • Verify the updated diagnostic wording in crates/vm/src/vm/vm_new.rs for clarity and correctness.

Poem

🐰 I nibble logs by lantern light,
Two names echo — what a sight!
A helpful panic, a gentle nudge,
So types behave and errors budge.
Hoppity hop, the fix is bright.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'init debug helper' is concise and clearly describes the main changes: adding debug-only helper logic to the init path for improved error diagnostics.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 080a2f6 and d5af480.

📒 Files selected for processing (2)
  • crates/vm/src/types/slot.rs (1 hunks)
  • crates/vm/src/vm/vm_new.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/vm/src/vm/vm_new.rs
  • crates/vm/src/types/slot.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run tests under miri
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets

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.