Skip to content

Commit 7a5b080

Browse files
committed
Gate BuiltinImporter and FrozenImporter load_module to Python < 3.15
1 parent 85ffb50 commit 7a5b080

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

stdlib/_frozen_importlib.pyi

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import importlib.abc
23
import importlib.machinery
34
import sys
@@ -60,8 +61,13 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
6061
# InspectLoader
6162
@classmethod
6263
def is_package(cls, fullname: str) -> bool: ...
63-
@classmethod
64-
def load_module(cls, fullname: str) -> types.ModuleType: ...
64+
65+
# Fixing the deprecation warning for `load_module` in Python 3.15 and later
66+
if sys.version_info < (3, 15):
67+
@classmethod
68+
@deprecated("Deprecated since Python 3.4; removed in Python 3.15. Use `exec_module()` instead.")
69+
def load_module(cls, fullname: str) -> types.ModuleType: ...
70+
6571
@classmethod
6672
def get_code(cls, fullname: str) -> None: ...
6773
@classmethod
@@ -94,8 +100,13 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
94100
# InspectLoader
95101
@classmethod
96102
def is_package(cls, fullname: str) -> bool: ...
97-
@classmethod
98-
def load_module(cls, fullname: str) -> types.ModuleType: ...
103+
104+
# Fixing the deprecation warning for `load_module` in Python 3.15 and later
105+
if sys.version_info < (3, 15):
106+
@classmethod
107+
@deprecated("Deprecated since Python 3.4; removed in Python 3.15. Use `exec_module()` instead.")
108+
def load_module(cls, fullname: str) -> types.ModuleType: ...
109+
99110
@classmethod
100111
def get_code(cls, fullname: str) -> None: ...
101112
@classmethod

0 commit comments

Comments
 (0)