From 7a5b0807685cf5f55c903b16c79d0e31faa6b637 Mon Sep 17 00:00:00 2001 From: raul-sq Date: Sun, 19 Jul 2026 11:48:00 +0200 Subject: [PATCH 1/3] Gate BuiltinImporter and FrozenImporter load_module to Python < 3.15 --- stdlib/_frozen_importlib.pyi | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 172da4522d8f..f1579b96ae98 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -1,3 +1,4 @@ + import importlib.abc import importlib.machinery import sys @@ -60,8 +61,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: ... + @classmethod def get_code(cls, fullname: str) -> None: ... @classmethod @@ -94,8 +100,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 From 3c4a348768940bcec270a7b7adca96c9b5ee3388 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2026 10:07:12 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_frozen_importlib.pyi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index f1579b96ae98..6428609364aa 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -1,4 +1,3 @@ - import importlib.abc import importlib.machinery import sys @@ -61,7 +60,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # InspectLoader @classmethod def is_package(cls, fullname: str) -> bool: ... - + # Fixing the deprecation warning for `load_module` in Python 3.15 and later if sys.version_info < (3, 15): @classmethod @@ -100,7 +99,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # InspectLoader @classmethod def is_package(cls, fullname: str) -> bool: ... - + # Fixing the deprecation warning for `load_module` in Python 3.15 and later if sys.version_info < (3, 15): @classmethod From 816872c4d9b6913e4bf26f7ea0e71ace61d7630c Mon Sep 17 00:00:00 2001 From: raul-sq Date: Sun, 19 Jul 2026 13:21:43 +0200 Subject: [PATCH 3/3] Remove fixed allowlist entries --- stdlib/@tests/stubtest_allowlists/py315.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py315.txt b/stdlib/@tests/stubtest_allowlists/py315.txt index 7354dac4dc90..b12827181d4e 100644 --- a/stdlib/@tests/stubtest_allowlists/py315.txt +++ b/stdlib/@tests/stubtest_allowlists/py315.txt @@ -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