mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42134: Raise ImportWarning when calling find_module() in the import system (GH-25044)
This commit is contained in:
parent
cf35e05f89
commit
a7ff6df60c
9 changed files with 1012 additions and 962 deletions
|
@ -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
|
||||
|
|
|
@ -1324,6 +1324,9 @@ class PathFinder:
|
|||
if hasattr(finder, 'find_loader'):
|
||||
loader, portions = finder.find_loader(fullname)
|
||||
else:
|
||||
msg = (f"{_bootstrap._object_name(finder)}.find_spec() not found; "
|
||||
"falling back to find_module()")
|
||||
_warnings.warn(msg, ImportWarning)
|
||||
loader = finder.find_module(fullname)
|
||||
portions = []
|
||||
if loader is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue