diff -r 53271aa4d84c Lib/os.py --- a/Lib/os.py Sat Jan 02 17:25:59 2016 -0500 +++ b/Lib/os.py Sun Jan 03 10:47:30 2016 +0200 @@ -356,6 +356,7 @@ def walk(top, topdown=True, onerror=None 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 @@ -410,7 +411,7 @@ def walk(top, topdown=True, onerror=None 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: @@ -427,6 +428,9 @@ def walk(top, topdown=True, onerror=None 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