@@ -607,6 +607,21 @@ def _requires_frozen_wrapper(self, fullname):
607607 return _requires_frozen_wrapper
608608
609609
610+ def _find_module_shim (self , fullname ):
611+ """Try to find a loader for the specified module by delegating to
612+ self.find_loader()."""
613+ # Call find_loader(). If it returns a string (indicating this
614+ # is a namespace package portion), generate a warning and
615+ # return None.
616+ loader , portions = self .find_loader (fullname )
617+ if loader is None and len (portions ):
618+ msg = "Not importing directory {}: missing __init__"
619+ _warnings .warn (msg .format (portions [0 ]), ImportWarning )
620+ return loader
621+
622+
623+
624+
610625# Loaders #####################################################################
611626
612627class BuiltinImporter :
@@ -1305,17 +1320,7 @@ def invalidate_caches(self):
13051320 """Invalidate the directory mtime."""
13061321 self ._path_mtime = - 1
13071322
1308- def find_module (self , fullname ):
1309- """Try to find a loader for the specified module."""
1310- # Call find_loader(). If it returns a string (indicating this
1311- # is a namespace package portion), generate a warning and
1312- # return None.
1313- loader , portions = self .find_loader (fullname )
1314- assert len (portions ) in [0 , 1 ]
1315- if loader is None and len (portions ):
1316- msg = "Not importing directory {}: missing __init__"
1317- _warnings .warn (msg .format (portions [0 ]), ImportWarning )
1318- return loader
1323+ find_module = _find_module_shim
13191324
13201325 def find_loader (self , fullname ):
13211326 """Try to find a loader for the specified module, or the namespace
0 commit comments