diff options
| author | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 20:21:01 (GMT) |
|---|---|---|
| committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 20:21:01 (GMT) |
| commit | 12ea86adcea986c5572c597b72253d839f4d303a (patch) | |
| tree | db1cf22fe78ad8f96da1f2d47a1928854b3564dd /Lib/os.py | |
| parent | b28df76ee2cdd0bb2a941bc179f347c26e4254f5 (diff) | |
| parent | 9b704ec9e1049788157a7f042ef765a4bb058b68 (diff) | |
| download | cpython-12ea86adcea986c5572c597b72253d839f4d303a.zip cpython-12ea86adcea986c5572c597b72253d839f4d303a.tar.gz cpython-12ea86adcea986c5572c597b72253d839f4d303a.tar.bz2 | |
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 |
