diff -r 4cd620d8c3f6 Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Tue Feb 25 16:03:14 2014 -0500 +++ b/Lib/importlib/_bootstrap.py Tue Feb 25 20:01:26 2014 -0500 @@ -1869,7 +1869,7 @@ loader, portions = finder.find_loader(fullname) else: loader = finder.find_module(fullname) - portions = None + portions = [] if loader is not None: return spec_from_loader(fullname, loader) spec = ModuleSpec(fullname, None) diff -r 4cd620d8c3f6 Lib/test/test_importlib/import_/test_path.py --- a/Lib/test/test_importlib/import_/test_path.py Tue Feb 25 16:03:14 2014 -0500 +++ b/Lib/test/test_importlib/import_/test_path.py Tue Feb 25 20:01:26 2014 -0500 @@ -116,5 +116,29 @@ FinderTests, importlib=importlib, machinery=machinery) +class PathEntryFinderTests: + + def test_finder_with_failing_find_module(self): + # PathEntryFinder with find_module() defined should work. + # Issue #20763. + class Finder: + path_location = 'test_finder_with_find_module' + def __init__(self, path): + if path != self.path_location: + raise ImportError + + @staticmethod + def find_module(fullname): + return None + + + with util.import_state(path=[Finder.path_location]+sys.path[:], + path_hooks=[Finder]): + self.machinery.PathFinder.find_spec('importlib') + +Frozen_PEFTests, Source_PEFTests = util.test_both( + PathEntryFinderTests, machinery=machinery) + + if __name__ == '__main__': unittest.main()