Use surrogateescape with outfilter.py

When switching to using log-file capture, we're getting

 [gentoo/build-succeeds] outfile.write(ts_line.encode('utf-8'))
 [gentoo/build-succeeds] UnicodeEncodeError: 'utf-8' codec can't
   encode character 'udcc5' in position 59: surrogates not allowed

Use surrogateescape [1] on the output to avoid this

[1] https://www.python.org/dev/peps/pep-0383/

Change-Id: I2c2c537296edfa5a8fe661a41bd5bfb3bfcf57e3
This commit is contained in:
Ian Wienand 2018-05-25 11:05:02 +10:00
parent 668c93b118
commit 596062b0f9

View File

@ -78,7 +78,8 @@ def main():
if sys.version_info < (3,): if sys.version_info < (3,):
outfile.write(ts_line) outfile.write(ts_line)
else: else:
outfile.write(ts_line.encode('utf-8')) outfile.write(
ts_line.encode('utf-8', errors='surrogateescape'))
outfile.flush() outfile.flush()