diff options
| author | Brett Cannon <brett@python.org> | 2014-11-21 17:19:28 (GMT) |
|---|---|---|
| committer | Brett Cannon <brett@python.org> | 2014-11-21 17:19:28 (GMT) |
| commit | b6e2556d8fbd172181aac09b7536563635af63a9 (patch) | |
| tree | 07dcdf2a20ae9d8c82ead835491ab6ed7eccfaaa /Lib/importlib/_bootstrap.py | |
| parent | 8314690a26501b3693f9a1f18c85f240a6c973bb (diff) | |
| download | cpython-b6e2556d8fbd172181aac09b7536563635af63a9.zip cpython-b6e2556d8fbd172181aac09b7536563635af63a9.tar.gz cpython-b6e2556d8fbd172181aac09b7536563635af63a9.tar.bz2 | |
Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists.
Thanks to Martin Panter for the bug report.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
| -rw-r--r-- | Lib/importlib/_bootstrap.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index b47ffad..fff9eac 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -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: |
