Fixes OSError: File name too long
when environment variable is too long
#36
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.
Resolves #35
Hello!
Pull request overview
OSError: File name too long
when environment variable is too long by try-catching for anOSError
, and ignoring it when it causes an error due toFile name too long
.Details
This PR complies with the
EAFP
"easier to ask for forgiveness than permission" style as recommended in the Python glossary. It simply writes out the set comprehension in full and wraps eachpath.exists()
call with atry-except
which simply considers a candidate path to be non-existent whenever it throwsFile name too long
.After this PR, the output of the same program as #35 outputs only
This is the expected behaviour here.
Lastly, the changes should be equivalently efficient as before.
Note
It may be possible that
path.exists()
can throw other exceptions that maybe should be ignored as well, but this PR only ignores theFile name too long
exception.Let me know if you need anything from me at this point!