[Python-checkins] cpython (merge 3.3 -> default): merge

brett.cannon python-checkins at python.org
Mon Apr 1 19:26:35 CEST 2013


http://hg.python.org/cpython/rev/9a44e845a90e
changeset:   83056:9a44e845a90e
parent:      83052:4fcd50a6dca7
parent:      83055:ac89e7bc0e2f
user:        Brett Cannon <brett at python.org>
date:        Mon Apr 01 13:25:40 2013 -0400
summary:
  merge

files:
  Lib/importlib/_bootstrap.py |    13 +-
  Misc/NEWS                   |     3 +
  Python/importlib.h          |  6921 +++++++++++-----------
  3 files changed, 3476 insertions(+), 3461 deletions(-)


diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -474,9 +474,9 @@
     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 @@
     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 @@
                     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, [])
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #17357: Add missing verbosity messages for -v/-vv that were lost during
+  the importlib transition.
+
 - Issue #17323: The "[X refs, Y blocks]" printed by debug builds has been
   disabled by default.  It can be re-enabled with the `-X showrefcount` option.
 
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list