diff options
author | Brett Cannon <brett@python.org> | 2013-04-01 17:25:40 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-04-01 17:25:40 (GMT) |
commit | daf4daa295b75b4f0c87b5051a59b0a81ba4dc70 (patch) | |
tree | 5d535c3d63d305d4d640dc749105a8fa7d4d5e7d /Lib/importlib | |
parent | 2d556f56db942364ceca2bc19630db56f75e302f (diff) | |
parent | f8ffec061755ea1c40ef5dcdc7c68178c1fb4c4d (diff) | |
download | cpython-daf4daa295b75b4f0c87b5051a59b0a81ba4dc70.zip cpython-daf4daa295b75b4f0c87b5051a59b0a81ba4dc70.tar.gz cpython-daf4daa295b75b4f0c87b5051a59b0a81ba4dc70.tar.bz2 |
merge
Diffstat (limited to 'Lib/importlib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index d80c2c0..e2ac7ce 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -474,9 +474,9 @@ def _get_sourcefile(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.""" - if sys.flags.verbose: + if sys.flags.verbose >= verbosity: if not message.startswith(('#', 'import ')): message = '# ' + message print(message.format(*args), file=sys.stderr) @@ -637,8 +637,9 @@ def _validate_bytecode_header(data, source_stats=None, name=None, path=None): raw_timestamp = data[4:8] raw_size = data[8:12] if magic != _MAGIC_BYTES: - msg = 'bad magic number in {!r}: {!r}'.format(name, magic) - raise ImportError(msg, **exc_details) + message = 'bad magic number in {!r}: {!r}'.format(name, magic) + _verbose_message(message) + raise ImportError(message, **exc_details) elif len(raw_timestamp) != 4: message = 'incomplete timestamp in {!r}'.format(name) _verbose_message(message) @@ -1390,11 +1391,13 @@ class FileFinder: is_namespace = True # Check for a file w/ a proper suffix exists. 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: - full_path = _path_join(self.path, tail_module + suffix) if _path_isfile(full_path): return (loader(fullname, full_path), []) if is_namespace: + _verbose_message('possible namespace for {}'.format(base_path)) return (None, [base_path]) return (None, []) |