Skip to content

refactor(robustness): convert 36 bare except: -> except Exception: (A-22 survey complete)#66

Merged
AVADSA25 merged 1 commit into
mainfrom
fix/pr3b2-silent-except-survey
May 22, 2026
Merged

refactor(robustness): convert 36 bare except: -> except Exception: (A-22 survey complete)#66
AVADSA25 merged 1 commit into
mainfrom
fix/pr3b2-silent-except-survey

Conversation

@AVADSA25
Copy link
Copy Markdown
Owner

Summary

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 (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, 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 ×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 swallows KeyboardInterrupt / 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 caught BaseException.

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 (the anchored regex + AST guard both ignore them).

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.

🤖 Generated with Claude Code

…-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>
@AVADSA25 AVADSA25 merged commit c39ed80 into main May 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants