-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix scandir() crash by returning [] when directory is not found (#13083) #13086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @delta87 for the contribution!
bd13b60
to
835d81b
Compare
Hmmm the failure is unrelated, will try to investigate this later. |
Once the fix is in and this PR gets rebased, hopefully things are all green again! |
for more information, see https://pre-commit.ci
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
for more information, see https://pre-commit.ci
835d81b
to
476e31a
Compare
Backport to 8.3.x: 💚 backport PR created✅ Backport PR branch: Backported as #13117 🤖 @patchback |
Fixes #13083 --------- Co-authored-by: Bruno Oliveira <[email protected]> (cherry picked from commit 3214263)
Fixes #13083 --------- Co-authored-by: Bruno Oliveira <[email protected]> (cherry picked from commit 3214263) Co-authored-by: delta87 <[email protected]>
This PR addresses issue #13083 by modifying the scandir function to handle the case where a non-existent directory is provided. Previously, the function did not return a result for such cases, potentially leading to unhandled errors. Now, if the directory does not exist, the function will return an empty list instead.
Changes made:
Updated scandir to catch FileNotFoundError and return an empty list if the directory does not exist.
Updated the function docstring to reflect the new behavior.
Testing:
Also two tests were added.
Closes #13083