@@ -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
0 commit comments