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.
This commit is contained in:
Brett Cannon 2013-01-11 15:40:12 -05:00
parent 8762595ef3
commit a9976b3e32
4 changed files with 1002 additions and 958 deletions

View file

@ -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.