From 73b59d1227fc488bd328ac18c73d773052bc110b Mon Sep 17 00:00:00 2001 From: Ziang Zhang Date: Mon, 8 Jun 2026 10:08:22 +0800 Subject: [PATCH] fix: avoid mutating global csv dialect in run_csv_view fallback When csv.Sniffer().sniff() fails, the fallback code called csv.get_dialect('excel') which returns the class itself, then mutated .delimiter on it. This permanently corrupted the global excel dialect for the process lifetime, affecting all subsequent CSV operations. Fix: use the built-in csv.excel_tab and csv.excel dialects directly based on the detected delimiter, avoiding any mutation. Closes #47 --- trushell/commands/data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trushell/commands/data.py b/trushell/commands/data.py index 422e4e0..8e63a4c 100644 --- a/trushell/commands/data.py +++ b/trushell/commands/data.py @@ -36,8 +36,7 @@ def run_csv_view(args: str) -> str: dialect = csv.Sniffer().sniff(sample, delimiters=",\t") except csv.Error: delimiter = "\t" if "\t" in sample else "," - dialect = csv.get_dialect("excel") - dialect.delimiter = delimiter + dialect = csv.excel_tab if delimiter == "\t" else csv.excel reader = csv.reader(handle, dialect) headers = next(reader, None)