GH-119169: Skip reversing sibling directories in os.[f]walk(topdown=False)#119473
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
os.walk(topdown=False), don't bother reversingwalk_dirs. This means that sibling directories are visited in a different order, but 1) that order is arbitrary and comes fromos.scandir(), and 2) unlike in top-down mode, users can't influence which directories are visited or in what order.This change caused
test_walk_bottom_upto fail. I think this test made assertions that were too specific and relied onos.scandir()returning things in a specific order. The test code is pretty hard to understand once you get into the details. I've replaced it with a version of the same test fromtest_pathlib_abc.py. The new test checks that every directory is yielded before all its ancestors, and after all its descendants, but does not check the order of its yielded siblings.os.walk()#119169