-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix isinstance #5869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix isinstance #5869
Conversation
WalkthroughTwo new methods were introduced in the type system to provide low-level, exception-free attribute lookups directly in the MRO, closely matching CPython's behavior. Object protocol logic was refactored for safety and clarity, and a new method for special method lookup was added, ensuring correct handling of descriptors and error masking as in CPython. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PyType
participant PyStrInterned
participant MRO
Caller->>PyType: lookup_ref(name: &PyStr, vm)
PyType->>PyStrInterned: Intern name
PyType->>MRO: find_name_in_mro(interned_name)
MRO-->>PyType: Return attribute value or None
PyType-->>Caller: Return Option<PyObjectRef>
sequenceDiagram
participant Caller
participant PyObject
participant PyType
participant MRO
participant Descriptor
Caller->>PyObject: lookup_special(attr: &PyStr, vm)
PyObject->>PyType: Get type and MRO
PyType->>MRO: Search for attr in MRO dicts
MRO-->>PyType: Return value or None
alt Found and is descriptor
PyType->>Descriptor: Call __get__(self, instance, owner)
Descriptor-->>PyType: Return result or None on exception
end
PyType-->>PyObject: Return Option<PyObjectRef>
PyObject-->>Caller: Return Option<PyObjectRef>
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (1)vm/src/builtins/type.rs (3)
🔇 Additional comments (6)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
76c7882
to
b295e4f
Compare
Summary by CodeRabbit