Issue #6716/2: Backslash-replace error output in compilall.
diff --git a/Lib/compileall.py b/Lib/compileall.py
index c3bf25a..eb5e24b 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -104,7 +104,10 @@
print('*** Error compiling', fullname, '...')
else:
print('*** ', end='')
- print(err.msg)
+ # escape non-printable characters in msg
+ msg = err.msg.encode(sys.stdout.encoding, errors='backslashreplace')
+ msg = msg.decode(sys.stdout.encoding)
+ print(msg)
success = 0
except (SyntaxError, UnicodeError, IOError) as e:
if quiet: