Bug report / test coverage gap
Lib/test/test_lazy_import/__init__.py has broad lazy import coverage, but it misses two practical state-transition scenarios after reification:
importlib.reload() on a module that was first imported lazily and then reified.
- Deleting
sys.modules[name] after reification and then importing again.
Why this matters
These are common import-state operations and can regress subtly when lazy import behavior changes.
Adding tests helps lock in expected semantics and prevents regressions in future import machinery refactors.
Proposed change
Add two tests in test_lazy_import:
Affected files
Lib/test/test_lazy_import/__init__.py
Version
- main (3.15 development branch)
Additional notes
This is test-only; no runtime behavior change is introduced.
Linked PRs
Bug report / test coverage gap
Lib/test/test_lazy_import/__init__.pyhas broad lazy import coverage, but it misses two practical state-transition scenarios after reification:importlib.reload()on a module that was first imported lazily and then reified.sys.modules[name]after reification and then importing again.Why this matters
These are common import-state operations and can regress subtly when lazy import behavior changes.
Adding tests helps lock in expected semantics and prevents regressions in future import machinery refactors.
Proposed change
Add two tests in
test_lazy_import:test_reload_after_lazy_reification_keeps_single_module_objectimportlib.reload().sys.modules[name].test_reimport_after_deleting_sys_modules_entry_creates_new_modulesys.modules[name].Affected files
Lib/test/test_lazy_import/__init__.pyVersion
Additional notes
This is test-only; no runtime behavior change is introduced.
Linked PRs