upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/cf_diff.py
diff options
context:
space:
mode:
authorDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 11:19:40 +0000
committerDominik <55330408+Dom-in@users.noreply.github.com>2026-11-22 11:27:00 +0000
commitf698bf22067aa1e08c1b957d937cb32b2c3e6674 (patch)
tree484d0a4bbc781d04b7a39f6afe447ca5fe2bc12d /tools/cf_diff.py
parentbb2e18421dac527374eb837c88b5063c5d96f81f (diff)
tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts its __main__ block the same way (stdout errors="replace"). tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes (analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/cf_diff.py')
-rw-r--r--tools/cf_diff.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/cf_diff.py b/tools/cf_diff.py
index aa1f41f73..741e21561 100644
--- a/tools/cf_diff.py
+++ b/tools/cf_diff.py
@@ -642,4 +642,8 @@ def main(argv=None):
642 642
643 643
644if __name__ == "__main__": 644if __name__ == "__main__":
645 try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
646 sys.stdout.reconfigure(errors="replace")
647 except (AttributeError, ValueError, OSError):
648 pass
645 sys.exit(main()) 649 sys.exit(main())