gladevcp: move return out of finally in SAVE_PROGRAM#4075
Open
grandixximo wants to merge 1 commit into
Open
Conversation
gtk_action.py had 'return npath' inside a finally: block. A return in finally swallows any in-flight exception and overrides earlier returns, so the except branch's 'return None' (the error path) was always clobbered: a failed save still returned the path and hid the exception. Dedent the return out of the finally so the finally only closes the file. On success the function returns npath; on a write error it now correctly returns None. Also silences the Python 3.12+ SyntaxWarning: 'return' in a 'finally' block. Surfaced by the ui-smoke tests (PR LinuxCNC#4054). Fixes LinuxCNC#4067
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.
gtk_action.py had
return npathinside a finally: block. A return infinally swallows any in-flight exception and overrides earlier returns,
so the except branch's
return None(the error path) was always clobbered:a failed save still returned the path and hid the exception.
Dedent the return out of the finally so the finally only closes the file.
On success the function returns the path; on a write error it now returns
None. Also silences the Python 3.12+ SyntaxWarning: 'return' in a 'finally'
block.
Surfaced in the ui-smoke review, PR #4054.
Fixes #4067
Test: py_compile clean with no SyntaxWarning; success returns path, write
error returns None.