summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/__init__.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2023-05-03 11:55:22 (GMT)
committerGitHub <noreply@github.com>2023-05-03 11:55:22 (GMT)
commit326997829d02458246dfd5b6d03297e2418bde52 (patch)
tree05b94e8dbb81f6b7a8d9054bd773c3cf24e0797e /Lib/importlib/__init__.py
parentbcea36f8db9ad4fd542b38997e065987e829cb9f (diff)
downloadcpython-326997829d02458246dfd5b6d03297e2418bde52.zip
cpython-326997829d02458246dfd5b6d03297e2418bde52.tar.gz
cpython-326997829d02458246dfd5b6d03297e2418bde52.tar.bz2
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/__init__.py')
-rw-r--r--Lib/importlib/__init__.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index 21d9dee..707c081 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -70,40 +70,6 @@ def invalidate_caches():
finder.invalidate_caches()
-def find_loader(name, path=None):
- """Return the loader for the specified module.
-
- This is a backward-compatible wrapper around find_spec().
-
- This function is deprecated in favor of importlib.util.find_spec().
-
- """
- warnings.warn('Deprecated since Python 3.4 and slated for removal in '
- 'Python 3.12; use importlib.util.find_spec() instead',
- DeprecationWarning, stacklevel=2)
- try:
- loader = sys.modules[name].__loader__
- if loader is None:
- raise ValueError(f'{name}.__loader__ is None')
- else:
- return loader
- except KeyError:
- pass
- except AttributeError:
- raise ValueError(f'{name}.__loader__ is not set') from None
-
- spec = _bootstrap._find_spec(name, path)
- # We won't worry about malformed specs (missing attributes).
- if spec is None:
- return None
- if spec.loader is None:
- if spec.submodule_search_locations is None:
- raise ImportError(f'spec for {name} missing loader', name=name)
- raise ImportError('namespace packages do not have loaders',
- name=name)
- return spec.loader
-
-
def import_module(name, package=None):
"""Import a module.