Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit daf4daa

Browse files
committed
merge
2 parents 2d556f5 + f8ffec0 commit daf4daa

3 files changed

Lines changed: 3468 additions & 3453 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ def _get_sourcefile(bytecode_path):
474474
return source_path if _path_isfile(source_stats) else bytecode_path
475475

476476

477-
def _verbose_message(message, *args):
477+
def _verbose_message(message, *args, verbosity=1):
478478
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
479-
if sys.flags.verbose:
479+
if sys.flags.verbose >= verbosity:
480480
if not message.startswith(('#', 'import ')):
481481
message = '# ' + message
482482
print(message.format(*args), file=sys.stderr)
@@ -637,8 +637,9 @@ def _validate_bytecode_header(data, source_stats=None, name=None, path=None):
637637
raw_timestamp = data[4:8]
638638
raw_size = data[8:12]
639639
if magic != _MAGIC_BYTES:
640-
msg = 'bad magic number in {!r}: {!r}'.format(name, magic)
641-
raise ImportError(msg, **exc_details)
640+
message = 'bad magic number in {!r}: {!r}'.format(name, magic)
641+
_verbose_message(message)
642+
raise ImportError(message, **exc_details)
642643
elif len(raw_timestamp) != 4:
643644
message = 'incomplete timestamp in {!r}'.format(name)
644645
_verbose_message(message)
@@ -1390,11 +1391,13 @@ def find_loader(self, fullname):
13901391
is_namespace = True
13911392
# Check for a file w/ a proper suffix exists.
13921393
for suffix, loader in self._loaders:
1394+
full_path = _path_join(self.path, tail_module + suffix)
1395+
_verbose_message('trying {}'.format(full_path), verbosity=2)
13931396
if cache_module + suffix in cache:
1394-
full_path = _path_join(self.path, tail_module + suffix)
13951397
if _path_isfile(full_path):
13961398
return (loader(fullname, full_path), [])
13971399
if is_namespace:
1400+
_verbose_message('possible namespace for {}'.format(base_path))
13981401
return (None, [base_path])
13991402
return (None, [])
14001403

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #17357: Add missing verbosity messages for -v/-vv that were lost during
14+
the importlib transition.
15+
1316
- Issue #17323: The "[X refs, Y blocks]" printed by debug builds has been
1417
disabled by default. It can be re-enabled with the `-X showrefcount` option.
1518

0 commit comments

Comments
 (0)