Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 19, 2026

Summary by CodeRabbit

  • New Features

    • Improved type descriptor management for Python type objects
    • Enhanced weak reference support within the type system
  • Chores

    • Added internal constant definitions to support advanced type system features

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This change adds a new public function to clear type descriptors from Python type objects while managing dict and weakref attributes, alongside introducing a new interned constant for weakref in the VM's context system.

Changes

Cohort / File(s) Summary
Type Descriptor Management
crates/vm/src/stdlib/sys.rs
Added _clear_type_descriptors() function that validates immutability status, removes dict and weakref descriptors from type attribute dictionaries, and updates type slots to propagate changes to subclasses.
VM Context Constants
crates/vm/src/vm/context.rs
Extended ConstName struct with new __weakref__ interned constant field via macro expansion, enabling access to this magic attribute symbol throughout the VM context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through types with care,
Clearing descriptors here and there,
weakref now finds its place,
In constants, interned with grace,
Spring cleaning for the VM's space! 🌱

🚥 Pre-merge checks | ✅ 3
✅ 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 'sys._clear_type_descriptors' directly and specifically names the new public function being added to the sys module, clearly identifying the primary change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@youknowone youknowone marked this pull request as ready for review January 19, 2026 07:22
@youknowone youknowone merged commit d7a885c into RustPython:main Jan 19, 2026
13 checks passed
@youknowone youknowone deleted the sys-lear_type_descriptors branch January 19, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant