| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📝 Walkthrough
WalkthroughRemoved has_standard_getattro() from PyObject and simplified isinstance/issubclass control flow to always resolve __class__ via vm.get_attribute_opt("__class__"), removing the prior pre-check branch and helper. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PyObject
participant VM
participant TypeUtils
Caller->>PyObject: object_isinstance(obj, cls)
alt cls is a type
PyObject->>TypeUtils: subtype check (is subclass)
TypeUtils-->>PyObject: result
else cls is not a type
PyObject->>VM: get_attribute_opt(obj, "__class__")
VM-->>PyObject: class_obj or None
alt class_obj found
PyObject->>TypeUtils: abstract_issubclass(class_obj, cls)
TypeUtils-->>PyObject: result
else not found
PyObject-->>Caller: return False
end
end
PyObject-->>Caller: final bool
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem🚥 Pre-merge checks | ✅ 3 ✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches 🧪 Generate unit tests (beta)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
The optimization to skip __class__ lookup based on getattro check was incorrect: a class can override __class__ as a property while still using standard __getattribute__. Revert to always performing the lookup, matching CPython's object_isinstance behavior.
There was a problem hiding this comment.
crates/vm/src/protocol/object.rs (1)🤖 Prompt for all review comments with AI agents579-607: Add focused regression tests for __class__-driven isinstance semantics.
Given this revert fixes a prior optimization, please add coverage for objects overriding __getattribute__/__class__ to prevent future regressions in this path.
🤖 Prompt for AI AgentsVerify each finding against the current code and only fix it if needed. In `@crates/vm/src/protocol/object.rs` around lines 579 - 607, Add focused regression tests that exercise object_isinstance's fallback path when instances override __getattribute__ or __class__; create tests that call isinstance(obj, SomeType) where obj provides a custom __getattribute__ and a dynamic __class__ attribute so the branch that uses vm.get_attribute_opt(self.to_owned(), identifier!(vm, __class__)) and then calls abstract_issubclass or PyTypeRef::try_from_object is executed; specifically target the code paths in object_isinstance (the branch guarded by let Some(i_cls) = vm.get_attribute_opt(...)) and ensure both the i_cls Type conversion (PyTypeRef::try_from_object) and the abstract_issubclass call are covered to detect regressions of the reverted optimization.
Verify each finding against the current code and only fix it if needed. Nitpick comments: In `@crates/vm/src/protocol/object.rs`: - Around line 579-607: Add focused regression tests that exercise object_isinstance's fallback path when instances override __getattribute__ or __class__; create tests that call isinstance(obj, SomeType) where obj provides a custom __getattribute__ and a dynamic __class__ attribute so the branch that uses vm.get_attribute_opt(self.to_owned(), identifier!(vm, __class__)) and then calls abstract_issubclass or PyTypeRef::try_from_object is executed; specifically target the code paths in object_isinstance (the branch guarded by let Some(i_cls) = vm.get_attribute_opt(...)) and ensure both the i_cls Type conversion (PyTypeRef::try_from_object) and the abstract_issubclass call are covered to detect regressions of the reverted optimization.
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 CommitsReviewing files that changed from the base of the PR and between 863fd73 and 864bf57.
📒 Files selected for processing (1)
Sorry, something went wrong.
* Revert __class__ lookup skip in object_isinstance The optimization to skip __class__ lookup based on getattro check was incorrect: a class can override __class__ as a property while still using standard __getattribute__. Revert to always performing the lookup, matching CPython's object_isinstance behavior. * Collapse nested if in object_isinstance for clippy
| Back | FazBrowse Home | New Git URL |
wrong optimization
Summary by CodeRabbit