diff options
author | Brett Cannon <brett@python.org> | 2013-01-11 20:40:12 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-01-11 20:40:12 (GMT) |
commit | a9976b3e32b612e33dc9f6d8874a88d028de7424 (patch) | |
tree | ee962bc60d43e5702d88347cebd3a4aa4a00f515 /Lib/importlib | |
parent | 8762595ef3fd807a67be4a97e0e5815d2abb0521 (diff) | |
download | cpython-a9976b3e32b612e33dc9f6d8874a88d028de7424.zip cpython-a9976b3e32b612e33dc9f6d8874a88d028de7424.tar.gz cpython-a9976b3e32b612e33dc9f6d8874a88d028de7424.tar.bz2 |
Issue #16730: Don't raise an exception in
importlib.machinery.FileFinder when the directory has become
unreadable or a file. This brings semantics in line with Python 3.2
import.
Reported and diagnosed by David Pritchard.
Diffstat (limited to 'Lib/importlib')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index a18ccc4..f647c2b 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1395,8 +1395,9 @@ class FileFinder: path = self.path try: contents = _os.listdir(path) - except FileNotFoundError: - # Directory has been removed since last import + except (FileNotFoundError, PermissionError, NotADirectoryError): + # Directory has either been removed, turned into a file, or made + # unreadable. contents = [] # We store two cached versions, to handle runtime changes of the # PYTHONCASEOK environment variable. |