@@ -766,17 +766,14 @@ def _path_hooks(cls, path):
766766 except ImportError :
767767 continue
768768 else :
769- raise ImportError ("no path hook found for {0}" .format (path ),
770- path = path )
769+ return None
771770
772771 @classmethod
773772 def _path_importer_cache (cls , path ):
774773 """Get the finder for the path from sys.path_importer_cache.
775774
776775 If the path is not in the cache, find the appropriate finder and cache
777- it. Because of NullImporter, some finder should be returned. The only
778- explicit fail case is if None is cached but the path cannot be used for
779- the default hook, for which ImportError is raised.
776+ it. If no finder is available, store None.
780777
781778 """
782779 if path == '' :
@@ -786,15 +783,6 @@ def _path_importer_cache(cls, path):
786783 except KeyError :
787784 finder = cls ._path_hooks (path )
788785 sys .path_importer_cache [path ] = finder
789- else :
790- if finder is None :
791- msg = ("'None' in sys.path_importer_cache[{!r}], so retrying "
792- "finder search; in future versions of Python 'None' "
793- "will represent no finder" .format (path ))
794- _warnings .warn (msg , ImportWarning )
795- del sys .path_importer_cache [path ]
796- finder = cls ._path_hooks (path )
797- sys .path_importer_cache [path ] = finder
798786 return finder
799787
800788 @classmethod
@@ -804,11 +792,8 @@ def find_module(cls, fullname, path=None):
804792 if path is None :
805793 path = sys .path
806794 for entry in path :
807- try :
808- finder = cls ._path_importer_cache (entry )
809- except ImportError :
810- continue
811- if finder :
795+ finder = cls ._path_importer_cache (entry )
796+ if finder is not None :
812797 loader = finder .find_module (fullname )
813798 if loader :
814799 return loader
@@ -1192,6 +1177,5 @@ def _install(sys_module, _imp_module):
11921177 supported_loaders = [(ExtensionFileLoader , _suffix_list (3 ), False ),
11931178 (SourceFileLoader , _suffix_list (1 ), True ),
11941179 (SourcelessFileLoader , _suffix_list (2 ), True )]
1195- sys .path_hooks .extend ([FileFinder .path_hook (* supported_loaders ),
1196- _imp .NullImporter ])
1180+ sys .path_hooks .extend ([FileFinder .path_hook (* supported_loaders )])
11971181 sys .meta_path .extend ([BuiltinImporter , FrozenImporter , PathFinder ])
0 commit comments