Merge pull request #34239 from vutny/file-find-broken-symlinks

file.find module: fix handling of broken symlinks
This commit is contained in:
Mike Place 2016-06-23 10:25:17 -07:00 committed by GitHub
commit f74f176bd5

View File

@ -640,17 +640,24 @@ class Finder(object):
for criterion in self.criteria:
if fstat is None and criterion.requires() & _REQUIRES_STAT:
fullpath = os.path.join(dirpath, name)
fstat = os.stat(fullpath)
try:
fstat = os.stat(fullpath)
except OSError:
fstat = os.lstat(fullpath)
if not criterion.match(dirpath, name, fstat):
matches = False
break
if matches:
if fullpath is None:
fullpath = os.path.join(dirpath, name)
for action in self.actions:
if (fstat is None and
action.requires() & _REQUIRES_STAT):
fstat = os.stat(fullpath)
try:
fstat = os.stat(fullpath)
except OSError:
fstat = os.lstat(fullpath)
result = action.execute(fullpath, fstat, test=self.test)
if result is not None:
yield result