diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2012-05-15 22:42:11 +0800 |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2012-05-15 22:42:11 +0800 |
commit | acfc26acb0dff670f68a59c82762e21e81cc7fb0 (patch) | |
tree | 2e1c5dde6999a37f4bcc41f8230e6b20af9c2d5e /Lib/os.py | |
parent | b26fe2f313143139f7666f125b097d9c92a494ff (diff) | |
parent | 66bfcc1b0f3b1eb4905b3ef1054b8afc1219aacb (diff) | |
download | cpython-git-acfc26acb0dff670f68a59c82762e21e81cc7fb0.tar.gz |
merge heads
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -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 |