small fixes by youknowone · Pull Request #6444 · RustPython/RustPython
Caution
Review failed
The pull request is closed.
Walkthrough
The changes modify error handling for 0-dimensional memoryviews and refactor trait method signatures in the VM's slot system. 0-dimensional memoryview length queries now raise TypeError instead of returning 1. Trait methods are refactored to use PyObjectRef instead of PyRef and routed through slot methods.
Changes
| Cohort / File(s) | Summary |
|---|---|
Memory view error handling crates/vm/src/builtins/memory.rs |
Modified PyMemoryView::__len__ to raise TypeError("0-dim memory has no length") for 0-dimensional memoryviews instead of returning length of 1 |
Slot trait method refactoring crates/vm/src/types/slot.rs |
Exposed slot_init as __init__ via #[pymethod(name = "__init__")]; removed public __init__ wrapper; refactored __getattribute__, __setattr__, and __delattr__ signatures from PyRef<Self> to PyObjectRef and updated routing to use slot methods (slot_getattro, slot_setattro) |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20–30 minutes
- Trait method signature changes in
slot.rs: Multiple trait methods changed receiver type fromPyRef<Self>toPyObjectRef, requiring careful verification that implementations across the codebase are compatible and that routing through slot methods produces equivalent behavior - Public method removal: The
__init__wrapper removal onInitializermay affect external trait implementations and should be verified for backward compatibility impact - Memory behavior change: Ensure 0-dimensional memoryview length query behavior is tested and expected by callers
Possibly related PRs
initdebug helper #6315: ModifiesInitializer::slot_initwith debug handling in its downcast path, directly related to theslot_initexposure in this PR
Poem
🐰 A rabbit hops through slots so keen,
Where traits now dance with refs unseen,
0-dim arrays cry "no length here!"
PyObjectRef routes clean and clear,
Errors bubble up with grace,
Refactored slots fill their place! ✨
✨ 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
📒 Files selected for processing (2)
crates/vm/src/builtins/memory.rs(1 hunks)crates/vm/src/types/slot.rs(3 hunks)
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.
Comment @coderabbitai help to get the list of available commands and usage tips.