fix: Prevent crash on file in PATH during discovery#2917
Merged
gaborbernat merged 3 commits intopypa:mainfrom Aug 1, 2025
Merged
fix: Prevent crash on file in PATH during discovery#2917gaborbernat merged 3 commits intopypa:mainfrom
gaborbernat merged 3 commits intopypa:mainfrom
Conversation
* Fix a crash that occurred when the PATH environment variable contained a file instead of a directory. * Add a check to ensure only directories are processed from the PATH. * Preserve existing behavior of skipping unreadable or empty directories. * Add a test case to verify that a file in PATH does not cause a crash. * Add additional tests to improve code coverage. Fixes pypa#2861 Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
…e contained a file. This was happening because I was trying to read the contents of the file as if it were a directory. To fix this, I'll now check to make sure that each entry in the PATH is a directory before I try to read from it. This will also preserve the original behavior of skipping unreadable or empty directories. I've also added a new test case to make sure that a file in the PATH doesn't cause a crash. I've also added some additional tests to improve code coverage and to fix a platform-specific issue in the test suite.
for more information, see https://pre-commit.ci
gaborbernat
approved these changes
Aug 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2861
tox -e fix)docs/changelogfolder