fix: remove redundant return in finally block (voice processing) - #23709
Closed
vanthinh6886 wants to merge 1 commit into
Closed
fix: remove redundant return in finally block (voice processing)#23709vanthinh6886 wants to merge 1 commit into
vanthinh6886 wants to merge 1 commit into
Conversation
The `_voice_stop_and_transcribe()` method in cli.py had a `return` statement inside a `finally` block (line 9303). In Python, `return` in `finally` silently swallows any exception being propagated — the exception is discarded and the function returns normally. Python 3.14 will emit SyntaxWarning for this pattern. The `return` was intended to prevent the voice auto-restart logic from running when the no-speech limit (3 consecutive) is reached. However, this guard is already redundant: the code sets `self._voice_continuous = False` two lines before, which makes the subsequent auto-restart condition (`self._voice_continuous and not submitted`) evaluate to False. Removing the `return` preserves the same control flow while eliminating the exception-swallowing bug.
Collaborator
22 tasks
Contributor
|
Thanks for the focused cleanup. The premise still holds on current main: Suggested changes
Automated hermes-sweeper review. |
Contributor
|
The return-in-finally restart race was fixed in #73520 via @brunopirz's #52004 (co-credit @liuhao1024's earliest #21100); this stale variant is superseded. Thanks! (Landed via #73520, merge |
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.
Problem
_voice_stop_and_transcribe()incli.pyhas areturnstatement inside afinallyblock (line 9303). In Python,returninfinallysilently swallows any exception being propagated — the exception is discarded and the function returns normally.Python 3.14 will emit
SyntaxWarningfor this pattern:Fix
Remove the redundant
returnstatement. Thereturnwas intended to prevent voice auto-restart when the no-speech limit (3 consecutive) is reached, but this guard is already redundant:Setting
_voice_continuous = Falsealready makes the subsequent auto-restart condition evaluate toFalse, so thereturnwas unnecessary. Removing it preserves identical control flow while eliminating the exception-swallowing bug.Before vs After
returninfinallyreturn_voice_continuous = FalseTests
ast.parse()returninfinallyremains