Description
On Python 3.14+, cli.py raises a SyntaxWarning at startup due to a return statement inside a finally block in the _voice_process_recording method (line 8700). This is a known pitfall since Python 3.8 — return in a finally block suppresses any exception that was propagating through the finally clause, and Python 3.14 now emits a SyntaxWarning for it.
Location
cli.py, method _voice_process_recording, around line 8681–8716
The Problem
The finally block (line 8681) contains business logic that includes a return statement (line 8700), which triggers the warning:
finally:
with self._voice_lock:
self._voice_processing = False
if hasattr(self, "_app") and self._app:
self._app.invalidate()
try:
if wav_path and os.path.isfile(wav_path):
os.unlink(wav_path)
except Exception:
pass
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 # <--- SyntaxWarning here
else:
self._no_speech_count = 0
if self._voice_continuous and not submitted and not self._voice_recording:
...
The Fix
Move the business logic out of the finally block:
finally:
with self._voice_lock:
self._voice_processing = False
if hasattr(self, "_app") and self._app:
self._app.invalidate()
try:
if wav_path and os.path.isfile(wav_path):
os.unlink(wav_path)
except Exception:
pass
# Business logic outside finally:
if not submitted:
...
else:
...
if self._voice_continuous and not submitted and not self._voice_recording:
...
Environment
- Python 3.14.4
- Hermes Agent v0.12.0
- Ubuntu 26.04 (WSL2)
- Warning:
SyntaxWarning: return in a finally block
Description
On Python 3.14+,
cli.pyraises aSyntaxWarningat startup due to areturnstatement inside afinallyblock in the_voice_process_recordingmethod (line 8700). This is a known pitfall since Python 3.8 —returnin afinallyblock suppresses any exception that was propagating through thefinallyclause, and Python 3.14 now emits aSyntaxWarningfor it.Location
cli.py, method_voice_process_recording, around line 8681–8716The Problem
The
finallyblock (line 8681) contains business logic that includes areturnstatement (line 8700), which triggers the warning:The Fix
Move the business logic out of the
finallyblock:Environment
SyntaxWarning: return in a finally block