summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2021-04-02 19:35:32 (GMT)
committerGitHub <noreply@github.com>2021-04-02 19:35:32 (GMT)
commitf97dc800689ba98783dac8dc51f87f7c6f413ac6 (patch)
treee51ae8f2bf8b3f5434ab4d8b37cd0eef87b62c4e /Lib/importlib
parentad442a674ca443feec43a88a2d3671784712e550 (diff)
downloadcpython-f97dc800689ba98783dac8dc51f87f7c6f413ac6.zip
cpython-f97dc800689ba98783dac8dc51f87f7c6f413ac6.tar.gz
cpython-f97dc800689ba98783dac8dc51f87f7c6f413ac6.tar.bz2
bpo-43672: raise ImportWarning when calling find_loader() (GH-25119)
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap_external.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 6c3e031..358c650 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1323,10 +1323,13 @@ class PathFinder:
# This would be a good place for a DeprecationWarning if
# we ended up going that route.
if hasattr(finder, 'find_loader'):
+ msg = (f"{_bootstrap._object_name(finder)}.find_spec() not found; "
+ "falling back to find_loader()")
+ _warnings.warn(msg, ImportWarning)
loader, portions = finder.find_loader(fullname)
else:
msg = (f"{_bootstrap._object_name(finder)}.find_spec() not found; "
- "falling back to find_module()")
+ "falling back to find_module()")
_warnings.warn(msg, ImportWarning)
loader = finder.find_module(fullname)
portions = []