Skip to content
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 #13083: Fix scandir() crash by returning [] when directory is not found (#13083) #13085

Closed
wants to merge 1 commit into from

Conversation

delta87
Copy link

@delta87 delta87 commented Dec 25, 2024

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

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Dec 25, 2024
@delta87 delta87 force-pushed the main branch 12 times, most recently from c310b71 to 929ba92 Compare December 26, 2024 01:42
@delta87 delta87 closed this Dec 26, 2024
@delta87 delta87 reopened this Dec 26, 2024
@delta87 delta87 changed the title fix #13083: handle symlink loops in scandir function (#13083) fix #13083: Fix scandir() crash by returning [] when directory is not found (#13083) Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition: collection error when directory is deleted before scandir() runs
1 participant