fix: handle OSError in pos_args path existence check#3847
Merged
gaborbernat merged 2 commits intotox-dev:mainfrom Mar 3, 2026
Merged
fix: handle OSError in pos_args path existence check#3847gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat merged 2 commits intotox-dev:mainfrom
Conversation
When positional arguments exceed the filesystem's filename length limit
(typically 255 characters), `Path.exists()` raises `OSError: [Errno 36]
File name too long` instead of returning `False`.
This causes `tox` to crash with an internal error when long `-k`
expressions are passed via `{posargs}`, e.g.:
tox -e py3 -- -k "test_foo or test_bar or test_baz or ..."
The traceback is:
File ".../tox/config/main.py", line 58, in pos_args
if path_arg.exists() and not path_arg.is_absolute():
OSError: [Errno 36] File name too long: 'test_foo or test_bar or ...'
This is because `pos_args()` checks each argument with `path_arg.exists()`
to determine whether to rewrite relative paths for `changedir`. An argument
that is too long for the filesystem clearly cannot be a path, so the fix
catches `OSError` and treats such arguments as non-paths.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
gaborbernat
approved these changes
Mar 3, 2026
Contributor
Author
|
that was quick -- kudos! |
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.
When positional arguments exceed the filesystem's filename length limit (typically 255 characters),
Path.exists()raisesOSError: [Errno 36] File name too longinstead of returningFalse.This causes
toxto crash with an internal error when long-kexpressions are passed via{posargs}, e.g.:The traceback is:
This is because
pos_args()checks each argument withpath_arg.exists()to determine whether to rewrite relative paths forchangedir. An argument that is too long for the filesystem clearly cannot be a path, so the fix catchesOSErrorand treats such arguments as non-paths.tox -e fix) [XXX]docs/changelogfolder --[XXX]: tried but failed to install sphinx... might try again later