From 071ec8449caf234f3255cdc083afd9db2eda399b Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Thu, 26 Nov 2026 09:23:38 -0500 Subject: [PATCH] address guard: the two programs set errors='replace' on stdout tests/test_tool_stdout_encoding.py requires it of every program's __main__ block. Co-Authored-By: Claude Opus 5.5 --- scripts/run_address_guard_gpu_test.py | 4 ++++ tools/address_guard.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scripts/run_address_guard_gpu_test.py b/scripts/run_address_guard_gpu_test.py index ea42bdfae..f7aa53366 100644 --- a/scripts/run_address_guard_gpu_test.py +++ b/scripts/run_address_guard_gpu_test.py @@ -126,4 +126,8 @@ def main(argv=None): if __name__ == "__main__": + try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode + sys.stdout.reconfigure(errors="replace") + except (AttributeError, ValueError, OSError): + pass sys.exit(main()) diff --git a/tools/address_guard.py b/tools/address_guard.py index 65297965e..1acbad528 100644 --- a/tools/address_guard.py +++ b/tools/address_guard.py @@ -103,4 +103,8 @@ def main(argv=None): if __name__ == "__main__": + try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode + sys.stdout.reconfigure(errors="replace") + except (AttributeError, ValueError, OSError): + pass sys.exit(main())