bpo-42134: Raise ImportWarning when calling find_module() in the import system (GH-25044)

This commit is contained in:
Brett Cannon 2021-03-30 08:43:03 -07:00 committed by GitHub
parent cf35e05f89
commit a7ff6df60c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1012 additions and 962 deletions

View file

@ -903,8 +903,9 @@ def _resolve_name(name, package, level):
def _find_spec_legacy(finder, name, path):
# This would be a good place for a DeprecationWarning if
# we ended up going that route.
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