summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/importlib/_bootstrap.py4
-rw-r--r--Lib/importlib/test/import_/test_path.py2
2 files changed, 4 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 44349a8..39cf76a 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -713,10 +713,12 @@ class PathFinder:
the default hook, for which ImportError is raised.
"""
+ if path == '':
+ path = _os.getcwd()
try:
finder = sys.path_importer_cache[path]
except KeyError:
- finder = cls._path_hooks(path if path != '' else _os.getcwd())
+ finder = cls._path_hooks(path)
sys.path_importer_cache[path] = finder
else:
if finder is None and default:
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
index b28f25d..61fe226 100644
--- a/Lib/importlib/test/import_/test_path.py
+++ b/Lib/importlib/test/import_/test_path.py
@@ -82,7 +82,7 @@ class FinderTests(unittest.TestCase):
with util.import_state(path=[path], path_hooks=[hook]):
loader = machinery.PathFinder.find_module(module)
self.assertIs(loader, importer)
- self.assertIn('', sys.path_importer_cache)
+ self.assertIn(os.getcwd(), sys.path_importer_cache)
class DefaultPathFinderTests(unittest.TestCase):