Gate BuiltinImporter and FrozenImporter load_module to Python < 3.15#16031
Open
raul-sq wants to merge 4 commits into
Open
Gate BuiltinImporter and FrozenImporter load_module to Python < 3.15#16031raul-sq wants to merge 4 commits into
raul-sq wants to merge 4 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
…/raul-sq/typeshed into fix-frozen-importlib-load-module
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
AlexWaygood
reviewed
Jul 19, 2026
Comment on lines
+66
to
+68
| @classmethod | ||
| @deprecated("Deprecated since Python 3.4; removed in Python 3.15. Use `exec_module()` instead.") | ||
| def load_module(cls, fullname: str) -> types.ModuleType: ... |
Member
There was a problem hiding this comment.
Interesting -- there's no deprecation warning at runtime:
% uvx python3.14
Python 3.14.5 (main, May 10 2026, 19:20:57) [Clang 22.1.3 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from _frozen_importlib import *
>>> BuiltinImporter.load_module('abc')
<module 'abc' (built-in)>
>>> FrozenImporter.load_module('abc')
<module 'abc' (frozen)>
>>> FrozenImporter.load_module('shutil')but I do see the general deprecation notice at https://docs.python.org/3.12/deprecations/index.html#pending-removal-in-python-3-15, so I think this is an appropriate use of @deprecated.
I feel like your existing comment doesn't add that much over what you can see in the code. Maybe get rid of it and replace it with a note that all load_module methods in importlib were deprecated, and link to https://docs.python.org/3.12/deprecations/index.html#pending-removal-in-python-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.
load_module()was removed in Python 3.15 (deprecated since Python 3.4;see the 3.15 What's New / importlib docs). This gates the declarations on
_frozen_importlib.BuiltinImporterand_frozen_importlib.FrozenImporterbehind
sys.version_info < (3, 15)with a@deprecatedmessage, followingthe existing
find_modulepattern in the same file.Addresses two TODO entries in
stdlib/@tests/stubtest_allowlists/py315.txt(entries intentionally left in place for now; will remove in a follow-up
commit once CI confirms).