Repository navigation
Convert native base references without consulting the Python class - #9090
Conversation
PyRef::into_base and Py::to_base cast the pointer directly instead of going through a class-based downcast. into_base no longer reaches unreachable_unchecked when the object's MRO omits the native base, and to_base drops the equivalent debug assertion. Extracted from RustPython#8963. Assisted-by: Codex:gpt-6 Assisted-by: Claude:claude-opus-5-5
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Extracted from #8963 by @1ndahous3 (the commit keeps their authorship).
PyRef::into_basewent through a class-baseddowncastand hitunreachable_uncheckedon failure. A downcast consults the object's MRO, while the physical base prefix is fixed at allocation, so an object whose class has a custommro()that omits the native base turned this into undefined behavior.Py::to_basehad the same assumption as a debug assertion.Both now cast the pointer directly. The
unsafe impl PySubclasscontract from #9012 is what guarantees the prefix, so no runtime check is needed, andinto_baseloses the downcast it used to perform.Not included from #8963: the native layout id, the
supports_native_layoutvtable entry, and the runtime assertion inupcast/upcast_ref.Testing
native_base_conversions_ignore_python_mrobuilds anOSErrorsubclass, replaces its MRO with[cls, object], and converts through two base levels by reference and by value.cargo test -p rustpython-vm --features threading --libandcargo clippy -p rustpython-vm --features threading --all-targets -- -D warningspass on macOS.AI assistance
Original change written with Codex (gpt-6); extraction and test trimmed with Claude (claude-opus-5-5).
🤖 Generated with Claude Code
Summary by CodeRabbit