aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2023-05-03 04:55:22 -0700
committerGitHub <noreply@github.com>2023-05-03 04:55:22 -0700
commit326997829d02458246dfd5b6d03297e2418bde52 (patch)
tree05b94e8dbb81f6b7a8d9054bd773c3cf24e0797e /Lib/importlib/_bootstrap.py
parentbcea36f8db9ad4fd542b38997e065987e829cb9f (diff)
downloadcpython-326997829d02458246dfd5b6d03297e2418bde52.tar.gz
cpython-326997829d02458246dfd5b6d03297e2418bde52.zip
gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)
* Remove deprecated classes from pkgutil * Remove some other PEP 302 obsolescence * Use find_spec instead of load_module * Remove more tests of PEP 302 obsolete APIs * Remove another bunch of tests using obsolete load_modules() * Remove deleted names from __all__ * Remove obsolete footnote * imp is removed * Remove `imp` from generated stdlib names * What's new and blurb * Update zipimport documentation for the removed methods * Fix some Windows tests * Remove any test (or part of a test) that references `find_module()`. * Use assertIsNone() / assertIsNotNone() consistently. * Update Doc/reference/import.rst * We don't need pkgutil._get_spec() any more either * test.test_importlib.fixtures.NullFinder * ...BadLoaderFinder.find_module * ...test_api.InvalidatingNullFinder.find_module * ...test.test_zipimport test of z.find_module * Suppress cross-references to find_loader and find_module * Suppress cross-references to Finder * Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader --------- Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py41
1 files changed, 1 insertions, 40 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index e4fcaa61e6d..c48fd506a0e 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -892,21 +892,6 @@ class BuiltinImporter:
else:
return None
- @classmethod
- def find_module(cls, fullname, path=None):
- """Find the built-in module.
-
- If 'path' is ever specified then the search is considered a failure.
-
- This method is deprecated. Use find_spec() instead.
-
- """
- _warnings.warn("BuiltinImporter.find_module() is deprecated and "
- "slated for removal in Python 3.12; use find_spec() instead",
- DeprecationWarning)
- spec = cls.find_spec(fullname, path)
- return spec.loader if spec is not None else None
-
@staticmethod
def create_module(spec):
"""Create a built-in module"""
@@ -1076,18 +1061,6 @@ class FrozenImporter:
spec.submodule_search_locations.insert(0, pkgdir)
return spec
- @classmethod
- def find_module(cls, fullname, path=None):
- """Find a frozen module.
-
- This method is deprecated. Use find_spec() instead.
-
- """
- _warnings.warn("FrozenImporter.find_module() is deprecated and "
- "slated for removal in Python 3.12; use find_spec() instead",
- DeprecationWarning)
- return cls if _imp.is_frozen(fullname) else None
-
@staticmethod
def create_module(spec):
"""Set __file__, if able."""
@@ -1170,16 +1143,6 @@ def _resolve_name(name, package, level):
return f'{base}.{name}' if name else base
-def _find_spec_legacy(finder, name, path):
- msg = (f"{_object_name(finder)}.find_spec() not found; "
- "falling back to find_module()")
- _warnings.warn(msg, ImportWarning)
- loader = finder.find_module(name, path)
- if loader is None:
- return None
- return spec_from_loader(name, loader)
-
-
def _find_spec(name, path, target=None):
"""Find a module's spec."""
meta_path = sys.meta_path
@@ -1200,9 +1163,7 @@ def _find_spec(name, path, target=None):
try:
find_spec = finder.find_spec
except AttributeError:
- spec = _find_spec_legacy(finder, name, path)
- if spec is None:
- continue
+ continue
else:
spec = find_spec(name, path, target)
if spec is not None: