From 4d3e294db18a6479f712b96e52d17be1e3381cd6 Mon Sep 17 00:00:00 2001 From: liuhao1024 Date: Mon, 13 Jul 2026 08:10:50 +0800 Subject: [PATCH] fix(voice): remove return-in-finally to fix Python 3.14+ SyntaxWarning Replace the return statement inside the finally block of _voice_stop_and_transcribe with a _stop_continuous flag. Python 3.14+ emits SyntaxWarning for return-in-finally because it silently suppresses in-flight exceptions. Fixes #21088 --- cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli.py b/cli.py index 560b5d9a2e37..00b31611114c 100644 --- a/cli.py +++ b/cli.py @@ -11327,13 +11327,14 @@ def _voice_stop_and_transcribe(self): pass # Track consecutive no-speech cycles to avoid infinite restart loops. + _stop_continuous = False if not submitted: self._no_speech_count = getattr(self, '_no_speech_count', 0) + 1 if self._no_speech_count >= 3: self._voice_continuous = False self._no_speech_count = 0 _cprint(f"{_DIM}No speech detected 3 times, continuous mode stopped.{_RST}") - return + _stop_continuous = True else: self._no_speech_count = 0 @@ -11341,7 +11342,10 @@ def _voice_stop_and_transcribe(self): # restart recording so the user can keep talking. # (When transcript IS submitted, process_loop handles restart # after chat() completes.) - if self._voice_continuous and not submitted and not self._voice_recording: + if (not _stop_continuous + and self._voice_continuous + and not submitted + and not self._voice_recording): def _restart_recording(): try: self._voice_start_recording()