From cfefe8b84f7848044df3fd6570fbc7079ab2155b Mon Sep 17 00:00:00 2001 From: Tai An Date: Thu, 10 Sep 2026 15:48:40 -0700 Subject: [PATCH] fix(simpy): report a non-UTF-8 resource CSV as unreadable, not as a bad integer (#259) UnicodeError is a ValueError subclass, so the 'invalid integer' handler was catching decode failures first. Swap the two except clauses so a non-UTF-8 CSV is reported as unreadable. --- skills/simpy/scripts/event_trace_summary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skills/simpy/scripts/event_trace_summary.py b/skills/simpy/scripts/event_trace_summary.py index cae7e043..1319081d 100644 --- a/skills/simpy/scripts/event_trace_summary.py +++ b/skills/simpy/scripts/event_trace_summary.py @@ -199,10 +199,10 @@ def summarize_resource_csv(path: Path, *, max_records: int) -> dict[str, Any]: } ) event_counts[event] += 1 - except ValueError as exc: - raise CliError(f"resource CSV contains an invalid integer: {exc}") from exc except (OSError, UnicodeError, csv.Error) as exc: raise CliError(f"cannot read resource CSV {path.name}: {exc}") from exc + except ValueError as exc: + raise CliError(f"resource CSV contains an invalid integer: {exc}") from exc if len(samples) < 2: raise CliError("resource CSV needs at least an initial and final sample") start = samples[0]["time"]