Issue #22834: Have import suppress FileNotFoundError when the current

working directory no longer exists.

Thanks to Martin Panter for the bug report.
This commit is contained in:
Brett Cannon 2014-11-21 12:19:28 -05:00
parent 8314690a26
commit b6e2556d8f
7 changed files with 1043 additions and 1001 deletions

View file

@ -1825,7 +1825,12 @@ class PathFinder:
"""
if path == '':
path = _os.getcwd()
try:
path = _os.getcwd()
except FileNotFoundError:
# Don't cache the failure as the cwd can easily change to
# a valid directory later on.
return None
try:
finder = sys.path_importer_cache[path]
except KeyError: