Skip to content

Commit f9941de

Browse files
committed
fix(audit): use ASCII-safe JSON output for Windows cp1252 compatibility
Remove ensure_ascii=False from json.dumps calls so Unicode characters (→, ❌) are escaped as \uXXXX sequences. This prevents UnicodeEncodeError on Windows where stdout defaults to cp1252 encoding. Also set PYTHONUTF8=1 in test subprocess environments as a safety net.
1 parent 40d0f3a commit f9941de

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

audit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def cmd_audit(args: argparse.Namespace) -> int:
404404
enriched_tools.append(enriched)
405405

406406
# Output JSON array to stdout
407-
print(json.dumps(enriched_tools, indent=2, ensure_ascii=False))
407+
print(json.dumps(enriched_tools, indent=2))
408408
return 0
409409

410410
# Table output mode
@@ -1074,7 +1074,7 @@ def cmd_versions(args: argparse.Namespace) -> int:
10741074
"runtimes": runtimes_data,
10751075
"total": len(runtimes_data),
10761076
}
1077-
print(json.dumps(output, indent=2, ensure_ascii=False))
1077+
print(json.dumps(output, indent=2))
10781078
return 0
10791079

10801080
# Table output mode

tests/test_update_fixes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def test_collect_node_generates_versioned_entries(self):
109109
env["CLI_AUDIT_JSON"] = "1"
110110
env["CLI_AUDIT_COLLECT"] = "1"
111111
env["CLI_AUDIT_MERGE"] = "1"
112+
env["PYTHONUTF8"] = "1"
112113

113114
result = subprocess.run(
114115
[sys.executable, "audit.py", "node@25"],
@@ -132,6 +133,7 @@ def test_collect_go_generates_versioned_entries(self):
132133
env["CLI_AUDIT_JSON"] = "1"
133134
env["CLI_AUDIT_COLLECT"] = "1"
134135
env["CLI_AUDIT_MERGE"] = "1"
136+
env["PYTHONUTF8"] = "1"
135137

136138
result = subprocess.run(
137139
[sys.executable, "audit.py", "go@1.25"],
@@ -151,6 +153,7 @@ def test_collect_empty_filter_does_not_crash(self):
151153
env = os.environ.copy()
152154
env["CLI_AUDIT_JSON"] = "1"
153155
env["CLI_AUDIT_COLLECT"] = "1"
156+
env["PYTHONUTF8"] = "1"
154157

155158
result = subprocess.run(
156159
[sys.executable, "audit.py", "nonexistent_tool_xyz"],

0 commit comments

Comments
 (0)