fix(cli): move return out of finally block in _voice_stop_and_transcribe (Python 3.14+)#21261
Open
wali-reheman wants to merge 1 commit into
Open
Conversation
Fixes SyntaxWarning on Python 3.14+ where a return statement inside a finally block suppresses any propagating exception. The business logic (track no-speech cycles, restart recording in continuous mode) is moved outside the finally block. Only the cleanup actions (release _voice_lock, invalidate app, remove temp wav file) remain in finally — all of which are safe to run even when an exception is propagating.
Collaborator
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.
Summary
Fixes Python 3.14 in caused by a statement inside a block.
Problem
Python 3.14 emits when a appears inside a block, because suppresses any exception that was propagating through the clause. This is a known Python anti-pattern since 3.8.
The method had the following structure:
Fix
Move the business logic outside the block. Only the cleanup actions remain in :
The following logic is now outside (at module level of the method, dedented by one level):
Changes
Testing
Python 3.14's flag will confirm the fix.
Related Issue
Closes #21088