Skip to content

Instantly share code, notes, and snippets.

@MorganRamsay
Created February 2, 2018 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorganRamsay/bae6dbd4415b2d78088607f0d7cc9941 to your computer and use it in GitHub Desktop.
Save MorganRamsay/bae6dbd4415b2d78088607f0d7cc9941 to your computer and use it in GitHub Desktop.
Python 3.6.4: os.walk (lines 402-409 in os.py) - fixed
for dirname in dirs:
new_path = join(top, dirname)
# Issue #23605: os.path.islink() is used instead of caching
# entry.is_symlink() result during the loop on os.scandir() because
# the caller can replace the directory entry during the "yield"
# above.
if followlinks or not islink(new_path):
yield from walk(new_path, topdown, onerror, followlinks)
else:
yield new_path, None, None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment