Skip to content

Fix builtin class names not being interned#8116

Open
ShaharNaveh wants to merge 1 commit into
RustPython:mainfrom
ShaharNaveh:fix-panic-interned-cls-name
Open

Fix builtin class names not being interned#8116
ShaharNaveh wants to merge 1 commit into
RustPython:mainfrom
ShaharNaveh:fix-panic-interned-cls-name

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Chores
    • Enhanced virtual machine startup by improving class and method definition registration mechanisms.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 427caa8f-13e1-4fa4-a53e-e9a037f3e20e

📥 Commits

Reviewing files that changed from the base of the PR and between dbfd69e and cd96f2c.

⛔ Files ignored due to path filters (2)
  • Lib/test/test_dataclasses/__init__.py is excluded by !Lib/**
  • Lib/test/test_pydoc/test_pydoc.py is excluded by !Lib/**
📒 Files selected for processing (4)
  • crates/vm/src/builtins/asyncgenerator.rs
  • crates/vm/src/function/method.rs
  • crates/vm/src/function/mod.rs
  • crates/vm/src/types/zoo.rs

📝 Walkthrough

Walkthrough

Adds a missing extend_class call for PyAsyncGenWrappedValue in the async generator builtins init. Separately, exposes the method submodule as pub(crate), imports PyClassDef, introduces a new pub(crate) fn init on HeapMethodDef that interns its name in the VM Context, and wires that call into TypeZoo::extend.

Changes

Type Registration and Init Wiring

Layer / File(s) Summary
PyAsyncGenWrappedValue registration fix
crates/vm/src/builtins/asyncgenerator.rs
Adds the missing PyAsyncGenWrappedValue::extend_class(...) call inside init so the wrapped-value type is registered alongside the other async-generator types.
HeapMethodDef init function, module visibility, and TypeZoo wiring
crates/vm/src/function/mod.rs, crates/vm/src/function/method.rs, crates/vm/src/types/zoo.rs
Makes the method submodule pub(crate), imports PyClassDef, adds a pub(crate) fn init that interns HeapMethodDef::NAME in the Context, and calls it from TypeZoo::extend.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested reviewers

  • youknowone

Poem

🐇 Hop, hop, a type was lost in the night,
extend_class missing — what a small fright!
Now WrappedValue joins the async parade,
And HeapMethodDef has a name newly made.
The zoo is complete, every class in its place,
This rabbit approves with a smile on its face! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: ensuring builtin class names are properly interned during initialization across multiple modules.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] lib: cpython/Lib/pydoc.py
[x] lib: cpython/Lib/pydoc_data
[ ] test: cpython/Lib/test/test_pydoc (TODO: 35)

dependencies:

  • pydoc

dependent tests: (5 tests)

  • pydoc: test_enum test_pydoc
    • pdb: test_pdb
    • xmlrpc.server: test_docxmlrpc test_xmlrpc

[x] lib: cpython/Lib/dataclasses.py
[x] test: cpython/Lib/test/test_dataclasses (TODO: 3)

dependencies:

  • dataclasses

dependent tests: (98 tests)

  • dataclasses: test__colorize test_copy test_ctypes test_enum test_genericalias test_patma test_pprint test_pydoc test_regrtest test_typing test_zoneinfo
    • pprint: test_htmlparser test_ssl test_sys_setprofile test_unittest
      • pdb: test_pdb
      • pickle: test_annotationlib test_argparse test_array test_ast test_asyncio test_bool test_builtin test_bytes test_bz2 test_codecs test_collections test_concurrent_futures test_configparser test_coroutines test_csv test_ctypes test_decimal test_defaultdict test_deque test_descr test_dict test_dictviews test_email test_enumerate test_exceptions test_fractions test_functools test_generators test_http_cookies test_importlib test_inspect test_io test_ipaddress test_iter test_itertools test_list test_logging test_lzma test_memoryio test_memoryview test_minidom test_opcache test_operator test_ordered_dict test_os test_pathlib test_pickle test_picklebuffer test_pickletools test_platform test_plistlib test_positional_only_arg test_posix test_random test_range test_re test_set test_shelve test_slice test_socket test_statistics test_str test_string test_structseq test_super test_time test_trace test_tuple test_turtle test_type_aliases test_type_params test_types test_unittest test_uuid test_xml_dom_minicompat test_xml_etree test_xpickle test_zipfile test_zlib test_zoneinfo
    • pstats: test_profile test_pstats

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

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