Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Dec 31, 2025

close #6523
fix #4565

Summary by CodeRabbit

  • Bug Fixes
    • Fixed module origin name resolution for frozen module imports to correctly map internal module aliases to their canonical names.

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

Copilot AI and others added 4 commits December 31, 2025 18:15
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request implements proper __origname__ metadata for frozen modules. A new public function resolve_frozen_alias maps internal frozen module alias names to their original counterparts, which is then used to correctly populate the __origname__ attribute during module initialization across the import and module systems.

Changes

Cohort / File(s) Summary
Alias Resolution Function
crates/vm/src/vm/mod.rs
Adds public resolve_frozen_alias(name: &str) -> &str function that maps internal frozen module aliases ("_frozen_importlib" → "importlib._bootstrap", "_frozen_importlib_external" → "importlib._bootstrap_external") to their original names; includes a test validating the alias resolution behavior (test appears duplicated in file).
Import Flow Updates
crates/vm/src/import.rs
Reworks import_frozen to fetch frozen objects directly from vm.state.frozen and construct code objects via vm.ctx.new_code; applies resolve_frozen_alias to derive the correct __origname__ attribute value instead of using the internal module name directly.
Frozen Module Resolution
crates/vm/src/stdlib/imp.rs
Exposes resolve_frozen_alias as a public re-export; updates find_frozen to resolve the origname via resolve_frozen_alias and convert the result to a Python string.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With frozen modules once unnamed,
Now aliases resolve their shame!
origname shines bright and true,
Bootstrap paths shine right on through!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3afd46 and 72f314d.

📒 Files selected for processing (3)
  • crates/vm/src/import.rs
  • crates/vm/src/stdlib/imp.rs
  • crates/vm/src/vm/mod.rs

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 December 31, 2025 12:12
@youknowone youknowone merged commit 7c8df94 into RustPython:main Dec 31, 2025
12 of 13 checks passed
@youknowone youknowone deleted the origname branch December 31, 2025 12:12
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.

Add proper __origname__ to frozen module

1 participant