summaryrefslogtreecommitdiff
path: root/Lib/os.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/os.py b/Lib/os.py
index c3f674ec3d..0ea7b6275f 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -356,6 +356,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
dirs = []
nondirs = []
+ walk_dirs = []
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.walk
@@ -414,7 +415,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
walk_into = not is_symlink
if walk_into:
- yield from walk(entry.path, topdown, onerror, followlinks)
+ walk_dirs.append(entry.path)
# Yield before recursion if going top down
if topdown:
@@ -431,6 +432,9 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
if followlinks or not islink(new_path):
yield from walk(new_path, topdown, onerror, followlinks)
else:
+ # Recurse into sub-directories
+ for new_path in walk_dirs:
+ yield from walk(new_path, topdown, onerror, followlinks)
# Yield after recursion if going bottom up
yield top, dirs, nondirs