Permalink
Browse files

sh_spec.py should only output utf-8 as well.

This fixes a crash that only happened when running 'test/spec.sh all',
not test/spec.sh var-op-other.  I think the encoding that Python uses
deepends on the terminal that stdout is connected to?
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 12, 2018
1 parent 04f7436 commit 4d3cd87d7925c418eadcf3ccb1c81e107584d45e
Showing with 5 additions and 3 deletions.
  1. +5 −3 test/sh_spec.py
View
@@ -770,10 +770,12 @@ def _WriteRaw(s):
# We output utf-8-encoded HTML. If we get invalid utf-8 as stdout
# (which is very possible), then show the ASCII repr().
try:
s2 = s.decode('utf-8')
s.decode('utf-8')
except UnicodeDecodeError:
s2 = repr(s) # ASCII representation
self.f.write(cgi.escape(s2))
valid_utf8 = repr(s) # ASCII representation
else:
valid_utf8 = s
self.f.write(cgi.escape(valid_utf8))
self.f.write('</pre>')
self.f.write('<i>stdout:</i> <br/>\n')

0 comments on commit 4d3cd87

Please sign in to comment.