Issue #8533: Write tracebacks and failed tests to sys.stderr instead of
sys.stdout to avoid UnicodeEncodeError (use backslashreplace error handler)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index c432ca4..ec49b95 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -939,8 +939,8 @@
         print("test", test, "crashed --", str(type) + ":", value)
         sys.stdout.flush()
         if verbose or debug:
-            traceback.print_exc(file=sys.stdout)
-            sys.stdout.flush()
+            traceback.print_exc(file=sys.stderr)
+            sys.stderr.flush()
         return FAILED, test_time
     else:
         if refleak: