llnl.util.filesystem.find: restore old error handling #47463
Merged
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.
The point of #41945 was to introduce a
max_depth
parameter tollnl.util.filesystem.find(root, ...)
.However, it also made
find(root, ...)
more pedantic, as it started raisingOSError
whenos.stat(root)
failed with any error code except ENOENT, andstarted raising
ValueError
ifroot
is not a directory.This should not have been part of the PR, since there's a disagreement about
how useful this is, as it requires the call site to be defensive, and there are
many call sites possibly also in private repositories. Apart from that raising a
mix of OSError and ValueError seems awkward, and no tests were added
to cover the unhappy code path. How to handle errors best can then be settled
better after
releases/v0.23
branches off.This commit restores the 8 year status quo of not erroring (the recursive
search was based on
os.walk
, and the non-recursive just onglob
, bothof which ignore all
OSError
s by default).