refactor(robustness): convert 36 bare except: -> except Exception: (A-22 survey complete)#66
Merged
Merged
Conversation
…-22 survey complete) Completes the A-22 silent-except survey deferred from PR-3B. ## Survey finding Per-site review of every remaining genuinely-silent `except: pass` in production (22 one-liners + multi-line kin): NONE are bug-hiders. They're all legitimate resource teardown (proc.terminate/kill/wait, os.unlink temp cleanup) or best-effort stat gathering (skills/system_info.py). The genuine silent bug-hiders were already fixed in PR-3B (A-3 subset + the post-LLM [SKILL:] tag). So no control-flow changes were made to those — adding logging to legitimate cleanup would be noise, and codec_audit._write must stay silent by design. ## The one concrete anti-pattern fixed 36 BARE `except:` (no exception type) across 12 production files: codec_dictate.py x16, codec.py x5, skills/system_info.py x4, codec_textassist.py x3, codec_core.py, setup_codec.py, + 6 skills (weather, pomodoro, password_generator, lucy, calculator, app_switch). A bare except also swallows KeyboardInterrupt / SystemExit / GeneratorExit, so Ctrl-C and clean shutdown could be silently eaten. All 36 converted to `except Exception:`. The string-template `except:` inside the deprecated build_session_script generator (codec_core L.append strings) was left untouched — those are code-gen strings, not real handlers. ## Verification AST-based regression guard tests/test_no_bare_except.py pins zero bare excepts in production (immune to string-template false positives, skips tests/). Full suite 1365 passing, 23 pre-existing failures unchanged (zero new). Manifest regenerated (7 skill files touched). A-22 fully closed. Reference: docs/audits/PHASE-1-CODE-QUALITY.md finding A-22. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Completes the A-22 silent-except survey deferred from PR-3B.
Survey finding
Per-site review of every remaining genuinely-silent
except: passin production (22 one-liners + multi-line kin): none are bug-hiders. They're all legitimate resource teardown (proc.terminate/kill/wait,os.unlinktemp cleanup) or best-effort stat gathering (skills/system_info.py). The genuine silent bug-hiders were already fixed in PR-3B (the A-3 subset + the post-LLM[SKILL:]tag). So no control-flow changes were made to those — adding logging to legitimate cleanup would be noise, andcodec_audit._writemust stay silent by design.The one concrete anti-pattern fixed
36 bare
except:(no exception type) across 12 production files:codec_dictate.py×16,codec.py×5,skills/system_info.py×4,codec_textassist.py×3,codec_core.py,setup_codec.py, + 6 skills (weather, pomodoro, password_generator, lucy, calculator, app_switch).A bare
except:also swallowsKeyboardInterrupt/SystemExit/GeneratorExit— so Ctrl-C and clean shutdown could be silently eaten. All 36 →except Exception:. Each was spot-checked: all are recoverable-error patterns (cleanup, config-load-returns-default, port-check-returns-False) — none intentionally caughtBaseException.The string-template
except:inside the deprecatedbuild_session_scriptgenerator (codec_coreL.append(...)strings) was left untouched — those are code-gen strings, not real handlers (the anchored regex + AST guard both ignore them).Verification
tests/test_no_bare_except.pypins zero bare excepts in production (immune to string-template false positives; skips tests/).A-22 fully closed.
Reference: docs/audits/PHASE-1-CODE-QUALITY.md finding A-22.
🤖 Generated with Claude Code