Skip to content

gladevcp: move return out of finally in SAVE_PROGRAM#4075

Merged
BsAtHome merged 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gtk_action-return-in-finally
Jun 1, 2026
Merged

gladevcp: move return out of finally in SAVE_PROGRAM#4075
BsAtHome merged 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/gtk_action-return-in-finally

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

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 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.

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
@BsAtHome BsAtHome merged commit 199c4d3 into LinuxCNC:master Jun 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gladevcp: 'return' inside finally in gtk_action.py swallows exceptions

2 participants