gh-115914: double use init filename_obj value in pythonrun.c function PyRun_AnyFileExFlags #115916
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.
gh-115914: double init filename_obj value in pythonrun.c function PyRun_AnyFileExFlags
Improvement:
Simplifying the code. This change makes the code easier to understand because filename_obj is guaranteed to have an initial value, eliminating the need to check for that value in a separate else block. This makes the code cleaner and easier to read.
Reduced chance of error. Initializing variables before using them is good programming practice. This helps prevent errors caused by using uninitialized variables, which could lead to undefined behavior.
Efficiency: Although the change seems minor from a performance perspective, it does improve coding style by ensuring that all variables are properly initialized before use. In this case, the modification is more about code readability and maintainability than a direct performance increase.