Prefer os.path.exists over os.stat try-catch#2463
Open
Avasam wants to merge 1 commit intomhammond:mainfrom
Open
Prefer os.path.exists over os.stat try-catch#2463Avasam wants to merge 1 commit intomhammond:mainfrom
os.path.exists over os.stat try-catch#2463Avasam wants to merge 1 commit intomhammond:mainfrom
Conversation
Avasam
commented
Jan 17, 2025
| @@ -18,13 +18,15 @@ | |||
|
|
|||
Collaborator
Author
There was a problem hiding this comment.
This module has been marked as deprecated for the past 18 years. A comment set it for removal around "2009 or so".
Would it be better to just remove it?
However it is used by win32/scripts/regsetup.py (checks the registry after Python registration). I'm not sure about a modern use case for the regsetup.py script either.
Fixes a few reportPossiblyUnboundVariable and possibly-undefined
fd951fb to
40caf46
Compare
Avasam
commented
Dec 10, 2025
| return 1 | ||
| except OSError as details: | ||
| return 0 | ||
| return os.path.exists(fname) |
Collaborator
Author
There was a problem hiding this comment.
TODO: remove this helper function entirely, it's in a scripts file, it's not public API
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.
Makes checking the existence of a path more idiomatic.
Reduces use of try-catch for logical flow.
Simplifies some code.
Solves a few "possibly unbound/undefined" variables as seen by type-checkers.