mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #17357: Add missing verbosity messages when running under
-v/-vv that were lost in the transition to importlib.
This commit is contained in:
parent
c35151cf41
commit
f8ffec0617
3 changed files with 4314 additions and 4296 deletions
|
@ -483,9 +483,9 @@ def _get_sourcefile(bytecode_path):
|
||||||
return source_path if _path_isfile(source_stats) else bytecode_path
|
return source_path if _path_isfile(source_stats) else bytecode_path
|
||||||
|
|
||||||
|
|
||||||
def _verbose_message(message, *args):
|
def _verbose_message(message, *args, verbosity=1):
|
||||||
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
|
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
|
||||||
if sys.flags.verbose:
|
if sys.flags.verbose >= verbosity:
|
||||||
if not message.startswith(('#', 'import ')):
|
if not message.startswith(('#', 'import ')):
|
||||||
message = '# ' + message
|
message = '# ' + message
|
||||||
print(message.format(*args), file=sys.stderr)
|
print(message.format(*args), file=sys.stderr)
|
||||||
|
@ -813,6 +813,7 @@ class _LoaderBasics:
|
||||||
raw_size = data[8:12]
|
raw_size = data[8:12]
|
||||||
if magic != _MAGIC_BYTES:
|
if magic != _MAGIC_BYTES:
|
||||||
msg = 'bad magic number in {!r}: {!r}'.format(fullname, magic)
|
msg = 'bad magic number in {!r}: {!r}'.format(fullname, magic)
|
||||||
|
_verbose_message(msg)
|
||||||
raise ImportError(msg, name=fullname, path=bytecode_path)
|
raise ImportError(msg, name=fullname, path=bytecode_path)
|
||||||
elif len(raw_timestamp) != 4:
|
elif len(raw_timestamp) != 4:
|
||||||
message = 'bad timestamp in {}'.format(fullname)
|
message = 'bad timestamp in {}'.format(fullname)
|
||||||
|
@ -1382,11 +1383,13 @@ class FileFinder:
|
||||||
is_namespace = True
|
is_namespace = True
|
||||||
# Check for a file w/ a proper suffix exists.
|
# Check for a file w/ a proper suffix exists.
|
||||||
for suffix, loader in self._loaders:
|
for suffix, loader in self._loaders:
|
||||||
|
full_path = _path_join(self.path, tail_module + suffix)
|
||||||
|
_verbose_message('trying {}'.format(full_path), verbosity=2)
|
||||||
if cache_module + suffix in cache:
|
if cache_module + suffix in cache:
|
||||||
full_path = _path_join(self.path, tail_module + suffix)
|
|
||||||
if _path_isfile(full_path):
|
if _path_isfile(full_path):
|
||||||
return (loader(fullname, full_path), [])
|
return (loader(fullname, full_path), [])
|
||||||
if is_namespace:
|
if is_namespace:
|
||||||
|
_verbose_message('possible namespace for {}'.format(base_path))
|
||||||
return (None, [base_path])
|
return (None, [base_path])
|
||||||
return (None, [])
|
return (None, [])
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 3.3.2?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #17357: Add missing verbosity output when using -v/-vv.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
8599
Python/importlib.h
8599
Python/importlib.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue