Issue #8663: distutils.log emulates backslashreplace error handler. Fix
compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if stdout
is not a TTY).
diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py
index 7588570..b301a83 100644
--- a/Lib/distutils/log.py
+++ b/Lib/distutils/log.py
@@ -27,6 +27,10 @@
                 stream = sys.stderr
             else:
                 stream = sys.stdout
+            if stream.errors == 'strict':
+                # emulate backslashreplace error handler
+                encoding = stream.encoding
+                msg = msg.encode(encoding, "backslashreplace").decode(encoding)
             stream.write('%s\n' % msg)
             stream.flush()