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())