◐ Shell
clean mode source ↗

GH-119169: Skip reversing sibling directories in `os.[f]walk(topdown=False)` by barneygale · Pull Request #119473 · python/cpython

@barneygale

…wn=False)`

In `os.walk(topdown=False)`, don't bother reversing `walk_dirs`. This means
that sibling directories are visited in a different order, but 1) that
order is arbitrary and comes from `os.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_up` to fail. I think this test made
assertions that were too specific and relied on `os.scandir()` returning
things in a specific order, and 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 from `test_pathlib_abc.py`.