summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2012-05-15 20:21:01 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2012-05-15 20:21:01 (GMT)
commit12ea86adcea986c5572c597b72253d839f4d303a (patch)
treedb1cf22fe78ad8f96da1f2d47a1928854b3564dd /Lib/os.py
parentb28df76ee2cdd0bb2a941bc179f347c26e4254f5 (diff)
parent9b704ec9e1049788157a7f042ef765a4bb058b68 (diff)
downloadcpython-12ea86adcea986c5572c597b72253d839f4d303a.zip
cpython-12ea86adcea986c5572c597b72253d839f4d303a.tar.gz
cpython-12ea86adcea986c5572c597b72253d839f4d303a.tar.bz2
merge heads
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/os.py b/Lib/os.py
index ed2a31e..af4990f 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -353,13 +353,23 @@ if _exists("openat"):
names = flistdir(topfd)
dirs, nondirs = [], []
for name in names:
- # Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
- # walk() which reports symlinks to directories as directories. We do
- # however check for symlinks before recursing into a subdirectory.
- if st.S_ISDIR(fstatat(topfd, name).st_mode):
- dirs.append(name)
- else:
- nondirs.append(name)
+ try:
+ # Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
+ # walk() which reports symlinks to directories as directories.
+ # We do however check for symlinks before recursing into
+ # a subdirectory.
+ if st.S_ISDIR(fstatat(topfd, name).st_mode):
+ dirs.append(name)
+ else:
+ nondirs.append(name)
+ except FileNotFoundError:
+ try:
+ # Add dangling symlinks, ignore disappeared files
+ if st.S_ISLNK(fstatat(topfd, name, AT_SYMLINK_NOFOLLOW)
+ .st_mode):
+ nondirs.append(name)
+ except FileNotFoundError:
+ continue
if topdown:
yield toppath, dirs, nondirs, topfd