diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-08-20 03:18:15 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-08-20 03:18:15 (GMT) |
commit | 48fec0539157db38a993ededb32a8f312ec09fb9 (patch) | |
tree | 4cea5afa658f50a6f4c5c46458241d02794bdd91 /Lib/importlib | |
parent | db7920b97874bf3988984fae57f4ca80fced558f (diff) | |
download | cpython-48fec0539157db38a993ededb32a8f312ec09fb9.zip cpython-48fec0539157db38a993ededb32a8f312ec09fb9.tar.gz cpython-48fec0539157db38a993ededb32a8f312ec09fb9.tar.bz2 |
Close #14846: Handle a sys.path entry going away
Diffstat (limited to 'Lib/importlib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index 471b380..4c1f2f9 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1367,7 +1367,11 @@ class FileFinder: def _fill_cache(self): """Fill the cache of potential modules and packages for this directory.""" path = self.path - contents = _os.listdir(path) + try: + contents = _os.listdir(path) + except FileNotFoundError: + # Directory has been removed since last import + contents = [] # We store two cached versions, to handle runtime changes of the # PYTHONCASEOK environment variable. if not sys.platform.startswith('win'): |