Skip to content

Conversation

@gorsing
Copy link
Contributor

@gorsing gorsing commented Feb 25, 2024

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.

@ghost
Copy link

ghost commented Feb 25, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Feb 25, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@gorsing gorsing changed the title gh-115914: double init filename_obj value in pythonrun.c function PyRun_AnyFileExFlags gh-115914: double use init filename_obj value in pythonrun.c function PyRun_AnyFileExFlags Feb 25, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 25, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@gpshead gpshead self-assigned this Feb 25, 2024
@gpshead gpshead merged commit f082a05 into python:main Feb 25, 2024
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
…PyRun_AnyFileExFlags (pythongh-115916)

This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…PyRun_AnyFileExFlags (pythongh-115916)

This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…PyRun_AnyFileExFlags (pythongh-115916)

This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
…PyRun_AnyFileExFlags (pythongh-115916)

This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants