summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2022-08-05 00:24:26 (GMT)
committerGitHub <noreply@github.com>2022-08-05 00:24:26 (GMT)
commite1182bc3776ea7cfdd3f82d5ba4fdfee40ae57ee (patch)
treea83cbfa65f28dd2de5cefdabecd7daa925152f28 /Lib/importlib
parent44f1f63ad5cf00b6f50cef0cc1a62c42632138be (diff)
downloadcpython-e1182bc3776ea7cfdd3f82d5ba4fdfee40ae57ee.zip
cpython-e1182bc3776ea7cfdd3f82d5ba4fdfee40ae57ee.tar.gz
cpython-e1182bc3776ea7cfdd3f82d5ba4fdfee40ae57ee.tar.bz2
gh-94619: Remove long deprecated methods module_repr() and load_module() (#94624)
* gh-94619: Remove long deprecated methods module_repr() and load_module() Closes #94619 * Update Misc/NEWS.d/next/Library/2022-07-06-14-57-33.gh-issue-94619.PRqKVX.rst Fix typo Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Brett Cannon <brett@python.org>
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_abc.py14
-rw-r--r--Lib/importlib/_bootstrap.py6
-rw-r--r--Lib/importlib/_bootstrap_external.py13
3 files changed, 1 insertions, 32 deletions
diff --git a/Lib/importlib/_abc.py b/Lib/importlib/_abc.py
index f80348f..0832056 100644
--- a/Lib/importlib/_abc.py
+++ b/Lib/importlib/_abc.py
@@ -38,17 +38,3 @@ class Loader(metaclass=abc.ABCMeta):
raise ImportError
# Warning implemented in _load_module_shim().
return _bootstrap._load_module_shim(self, fullname)
-
- def module_repr(self, module):
- """Return a module's repr.
-
- Used by the module type when the method does not raise
- NotImplementedError.
-
- This method is deprecated.
-
- """
- warnings.warn("importlib.abc.Loader.module_repr() is deprecated and "
- "slated for removal in Python 3.12", DeprecationWarning)
- # The exception will cause ModuleType.__repr__ to ignore this method.
- raise NotImplementedError
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index afb95f4..67989c5 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -296,11 +296,6 @@ def _module_repr(module):
loader = getattr(module, '__loader__', None)
if spec := getattr(module, "__spec__", None):
return _module_repr_from_spec(spec)
- elif hasattr(loader, 'module_repr'):
- try:
- return loader.module_repr(module)
- except Exception:
- pass
# Fall through to a catch-all which always succeeds.
try:
name = module.__name__
@@ -582,7 +577,6 @@ def module_from_spec(spec):
def _module_repr_from_spec(spec):
"""Return the repr to use for the module."""
- # We mostly replicate _module_repr() using the spec attributes.
name = '?' if spec.name is None else spec.name
if spec.origin is None:
if spec.loader is None:
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index b6c6716..82d2042 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1339,22 +1339,11 @@ class _NamespacePath:
# This class is actually exposed publicly in a namespace package's __loader__
# attribute, so it should be available through a non-private name.
-# https://bugs.python.org/issue35673
+# https://github.com/python/cpython/issues/92054
class NamespaceLoader:
def __init__(self, name, path, path_finder):
self._path = _NamespacePath(name, path, path_finder)
- @staticmethod
- def module_repr(module):
- """Return repr for the module.
-
- The method is deprecated. The import machinery does the job itself.
-
- """
- _warnings.warn("NamespaceLoader.module_repr() is deprecated and "
- "slated for removal in Python 3.12", DeprecationWarning)
- return '<module {!r} (namespace)>'.format(module.__name__)
-
def is_package(self, fullname):
return True