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

[PR #13086/3214263b backport][8.3.x] Fix scandir() crash by returning [] when directory is not found (#13083) #13117

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Jan 8, 2025

This is a backport of PR #13086 as merged into main (3214263).

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

Fixes #13083

---------

Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit 3214263)
@nicoddemus nicoddemus enabled auto-merge (squash) January 8, 2025 21:12
@nicoddemus nicoddemus disabled auto-merge January 8, 2025 21:29
@nicoddemus nicoddemus merged commit f1c6bab into 8.3.x Jan 8, 2025
28 checks passed
@nicoddemus nicoddemus deleted the patchback/backports/8.3.x/3214263b2f0d17b265c40cf5f87d70357b9a219d/pr-13086 branch January 8, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants