diff -r a97d317dec85 Lib/site.py --- a/Lib/site.py Mon Mar 21 17:26:04 2016 +0100 +++ b/Lib/site.py Sat Mar 26 18:29:56 2016 +0100 @@ -131,13 +131,15 @@ def _init_pathinfo(): - """Return a set containing all existing directory entries from sys.path""" + """Return a set containing all existing entries from sys.path""" d = set() for dir in sys.path: try: - if os.path.isdir(dir): + if os.path.isdir(dir) or os.path.isfile(dir): dir, dircase = makepath(dir) d.add(dircase) + else: + d.add(dir) except TypeError: continue return d diff -r a97d317dec85 Lib/test/test_site.py --- a/Lib/test/test_site.py Mon Mar 21 17:26:04 2016 +0100 +++ b/Lib/test/test_site.py Sat Mar 26 18:29:56 2016 +0100 @@ -73,9 +73,12 @@ self.assertEqual(os.path.normcase(abs_dir), norm_dir) def test_init_pathinfo(self): + sys.path.extend(("/test.zip", "/testsub.zip/subpath")) + sys.path.append("https://www.python.org/testpackage") dir_set = site._init_pathinfo() - for entry in [site.makepath(path)[1] for path in sys.path - if path and os.path.isdir(path)]: + for entry in [path for path in sys.path if path]: + if os.path.isdir(entry) or os.path.isfile(entry): + _, entry = site.makepath(entry) self.assertIn(entry, dir_set, "%s from sys.path not found in set returned " "by _init_pathinfo(): %s" % (entry, dir_set))