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

Bug fix/scandir collection error #13084

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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