Skip to content

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

Merged
nicoddemus merged 1 commit into8.3.xfrom
patchback/backports/8.3.x/3214263b2f0d17b265c40cf5f87d70357b9a219d/pr-13086
Jan 8, 2025
Merged

[PR #13086/3214263b backport][8.3.x] Fix scandir() crash by returning [] when directory is not found (#13083)#13117
nicoddemus merged 1 commit into8.3.xfrom
patchback/backports/8.3.x/3214263b2f0d17b265c40cf5f87d70357b9a219d/pr-13086

Conversation

@patchback
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 <bruno@soliv.dev>
(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
@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