Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121604: Make sure all deprecated items in importlib raise DeprecationWarning #128007

Merged
merged 15 commits into from
Jan 15, 2025
Merged
Prev Previous commit
Next Next commit
Unify quotes
  • Loading branch information
tomasr8 committed Dec 16, 2024
commit 7079bddfccd54ba3a1f87b6e633189ae0a63d618
8 changes: 4 additions & 4 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@ class WindowsRegistryFinder:

def __init__(self):
import warnings
warnings.warn("importlib.machinery.WindowsRegistryFinder is "
"deprecated. Use site configuration instead. "
"Future versions of Python may not enable this "
"finder by default.",
warnings.warn('importlib.machinery.WindowsRegistryFinder is '
'deprecated. Use site configuration instead. '
'Future versions of Python may not enable this '
'finder by default.',
tomasr8 marked this conversation as resolved.
Show resolved Hide resolved
DeprecationWarning, stacklevel=2)

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class ResourceLoader(Loader):

def __init__(self):
import warnings
warnings.warn("importlib.abc.ResourceLoader is deprecated in "
"favour of supporting resource loading through "
"importlib.resources.abc.ResourceReader.",
warnings.warn('importlib.abc.ResourceLoader is deprecated in '
'favour of supporting resource loading through '
'importlib.resources.abc.ResourceReader.',
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
DeprecationWarning, stacklevel=2)
super().__init__()

Expand Down Expand Up @@ -209,8 +209,8 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo
def path_mtime(self, path):
"""Return the (int) modification time for the path (str)."""
import warnings
warnings.warn("SourceLoader.path_mtime is deprecated in favour of "
"SourceLoader.path_stats().",
warnings.warn('SourceLoader.path_mtime is deprecated in favour of '
'SourceLoader.path_stats().',
DeprecationWarning,
stacklevel=2)
if self.path_stats.__func__ is SourceLoader.path_stats:
Expand Down
14 changes: 7 additions & 7 deletions Lib/importlib/machinery.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ def __getattr__(name):
import warnings

if name == 'DEBUG_BYTECODE_SUFFIXES':
warnings.warn("importlib.machinery.DEBUG_BYTECODE_SUFFIXES is "
"deprecated. Use importlib.machinery.BYTECODE_SUFFIXES "
"instead.",
warnings.warn('importlib.machinery.DEBUG_BYTECODE_SUFFIXES is '
'deprecated. Use importlib.machinery.BYTECODE_SUFFIXES '
tomasr8 marked this conversation as resolved.
Show resolved Hide resolved
'instead.',
DeprecationWarning, stacklevel=2)
return _DEBUG_BYTECODE_SUFFIXES
elif name == 'OPTIMIZED_BYTECODE_SUFFIXES':
warnings.warn("importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES is "
"deprecated. Use importlib.machinery.BYTECODE_SUFFIXES "
"instead.",
warnings.warn('importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES is '
'deprecated. Use importlib.machinery.BYTECODE_SUFFIXES '
tomasr8 marked this conversation as resolved.
Show resolved Hide resolved
'instead.',
DeprecationWarning, stacklevel=2)
return _OPTIMIZED_BYTECODE_SUFFIXES

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
Loading