diff options
author | Brett Cannon <brett@python.org> | 2021-03-26 11:55:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 11:55:07 -0700 |
commit | 1899087b21119c5c64cd41619b542c0bf0ab5751 (patch) | |
tree | 400c834041ef28eacaac8fa0169e2482dea8a775 /Lib/importlib/_bootstrap.py | |
parent | 21a2cabb3795f5170c746ab8f29e9d25c7442550 (diff) | |
download | cpython-1899087b21119c5c64cd41619b542c0bf0ab5751.tar.gz cpython-1899087b21119c5c64cd41619b542c0bf0ab5751.zip |
bpo-42136: Deprecate module_repr() as found in importlib (GH-25022)
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 5038b46a018..d5acb6545f8 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -302,8 +302,6 @@ def _module_repr(module): except Exception: pass # Fall through to a catch-all which always succeeds. - # We could use module.__class__.__name__ instead of 'module' in the - # various repr permutations. try: name = module.__name__ except AttributeError: @@ -741,6 +739,8 @@ class BuiltinImporter: The method is deprecated. The import machinery does the job itself. """ + _warnings.warn("BuiltinImporter.module_repr() is deprecated and " + "slated for removal in Python 3.12", DeprecationWarning) return f'<module {module.__name__!r} ({BuiltinImporter._ORIGIN})>' @classmethod @@ -816,6 +816,8 @@ class FrozenImporter: The method is deprecated. The import machinery does the job itself. """ + _warnings.warn("FrozenImporter.module_repr() is deprecated and " + "slated for removal in Python 3.12", DeprecationWarning) return '<module {!r} ({})>'.format(m.__name__, FrozenImporter._ORIGIN) @classmethod |