Add the eager-runtime hook required by Python 3.15 importlib - #8946
Draft
youknowdot wants to merge 1 commit into
Draft
youknowdot wants to merge 1 commit into
youknowdot wants to merge 1 commit into
Conversation
Expose _imp._set_lazy_attributes(modobj, name, /), used by CPython 3.15 importlib after eager loading. Match its empty pending-lazy-module registry behavior, including name type and string-subclass hashing checks. This does not implement lazy imports or change the target version or bundled libraries. Assisted-by: Codex:model-version-unavailable
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
fanninpm
reviewed
Oct 2, 2026
Contributor
There was a problem hiding this comment.
Is this also in CPython 3.15's Lib/test directory? If so, it will eventually be migrated over to RustPython when RustPython begins targeting CPython 3.15.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
_imp._set_lazy_attributes(modobj, name, /), the private hook required by CPython 3.15 importlib after module loading.In CPython v3.15.0rc2, this hook discards
namefrom the pending lazy-module registry. RustPython currently executes imports eagerly and has no pending lazy entries. The implementation therefore validates the arguments and preserves string-subclass hashing (including exceptions), without modifying the module object.This is a small native prerequisite for the target/site/importlib/test-support migration. It does not implement PEP 810 lazy imports. When a real lazy-module registry is introduced, this hook must remove the corresponding pending entry.
Only
_imp.rsand one regression snippet change. The target version, bundled libraries, compiler, sentinel builtin, and cached import callback remain unchanged. The callback adjustment stays with the importlib migration, whose hierarchical-lock changes are needed for the concurrent-import cases.Validation
Hook-only branch at
29d5ba99196b4a41c48946ee90ab762d5affa739:site/importlib/test.support, and the original cached import callback; no sentinel orcompile(module=...)code is present-m test test_site test_support test_importlib test_pkgutil test_import --timeout 180: 1,676 run, 113 skipped; all five suites successfulThe identical hook code also passed full Rust validation in the broader native-import candidate
e2f1ed22366d258f4352e5ffaccebefa0bbfe467: workspace 1,345 passed/18 ignored, separate C-API 115 passed/4 ignored, and both all-targets Clippy commands clean. Those full Rust aggregates were not rerun after dropping the separate cached-importer change; the smaller branch was independently rebuilt and runtime-tested as above. No full Python 3.15 compatibility claim is made.The snippet follows the existing
skip_if_unsupportedconvention: every assertion always runs on RustPython; only the CPython comparison below 3.15 skips this unavailable API. It also runs separately against exact CPython 3.15.0rc2, commit435c9e5a798c99653e3ab64ce29baed0e4f3dfee.AI assistance
OpenAI Codex assisted with implementation, CPython comparison, tests, review, and this description under maintainer direction. The runtime did not expose the exact model version. Reported checks are automated Linux x86_64 verification; no additional human-use or untested-platform validation is claimed.