Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-119169: Skip reversing sibling directories in os.[f]walk(topdown=False) #119473

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Also undo reversals in os.fwalk()
  • Loading branch information
barneygale committed May 30, 2024
commit cfc60ceb3bddd04bdd90485c11c25765f18395ce
6 changes: 4 additions & 2 deletions Lib/os.py
Original file line number Diff line number Diff line change
@@ -553,13 +553,15 @@ def _fwalk(stack, isbytes, topdown, onerror, follow_symlinks):

toppath = path.join(toppath, toppath[:0]) # Add trailing slash.
if entries is None:
if topdown:
dirs = dirs[::-1]
stack.extend(
(_fwalk_walk, (False, topfd, toppath + name, name, None))
for name in dirs[::-1])
for name in dirs)
else:
stack.extend(
(_fwalk_walk, (False, topfd, toppath + name, name, entry))
for name, entry in zip(dirs[::-1], entries[::-1]))
for name, entry in zip(dirs, entries))

__all__.append("fwalk")

Loading