Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions stdlib/@tests/stubtest_allowlists/py315.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# TODO: Allowlist entries that should be fixed
# ============================================

_frozen_importlib.BuiltinImporter.load_module
_frozen_importlib.FrozenImporter.load_module
_frozen_importlib_external.FileFinder.discover
_frozen_importlib_external.NamespaceLoader.load_module
_frozen_importlib_external.NamespacePath
Expand Down
18 changes: 14 additions & 4 deletions stdlib/_frozen_importlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
# InspectLoader
@classmethod
def is_package(cls, fullname: str) -> bool: ...
@classmethod
def load_module(cls, fullname: str) -> types.ModuleType: ...

# Fixing the deprecation warning for `load_module` in Python 3.15 and later
if sys.version_info < (3, 15):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.15. Use `exec_module()` instead.")
def load_module(cls, fullname: str) -> types.ModuleType: ...
Comment on lines +66 to +68

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?


@classmethod
def get_code(cls, fullname: str) -> None: ...
@classmethod
Expand Down Expand Up @@ -94,8 +99,13 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# InspectLoader
@classmethod
def is_package(cls, fullname: str) -> bool: ...
@classmethod
def load_module(cls, fullname: str) -> types.ModuleType: ...

# Fixing the deprecation warning for `load_module` in Python 3.15 and later
if sys.version_info < (3, 15):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.15. Use `exec_module()` instead.")
def load_module(cls, fullname: str) -> types.ModuleType: ...

@classmethod
def get_code(cls, fullname: str) -> None: ...
@classmethod
Expand Down