summaryrefslogtreecommitdiff
path: root/Lib/os.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-05-15 22:42:11 +0800
committerSenthil Kumaran <senthil@uthcode.com>2012-05-15 22:42:11 +0800
commitacfc26acb0dff670f68a59c82762e21e81cc7fb0 (patch)
tree2e1c5dde6999a37f4bcc41f8230e6b20af9c2d5e /Lib/os.py
parentb26fe2f313143139f7666f125b097d9c92a494ff (diff)
parent66bfcc1b0f3b1eb4905b3ef1054b8afc1219aacb (diff)
downloadcpython-git-acfc26acb0dff670f68a59c82762e21e81cc7fb0.tar.gz
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 ed2a31e881..af4990fb8b 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