Skip to content

Conversation

@aday2418
Copy link

Closes #13083

I added a quick check to the scandir() function to ensure that the directory to scan still exists, and was not deleted during collection. This error handling keeps the function from crashing by catching the FileNotFoundError and returning if found.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Dec 24, 2024
@marcelotrevisani
Copy link
Contributor

Can you add a test for this case please?

@nicoddemus
Copy link
Member

Can you add a test for this case please?

Indeed. In this case a simple unittest will suffice: call the changed scandir function passing an non-existent directory, and ensure it returns []. The previous version of the function would raise an error in that case.

@nicoddemus
Copy link
Member

nicoddemus commented Dec 26, 2024

#13086 also implements a solution with tests, however I like this one's implementation better.

@nicoddemus
Copy link
Member

Superseded by #13086, thanks anyway @aday2418!

@nicoddemus nicoddemus closed this Jan 12, 2025
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

3 participants