Bug 1404733 - Handle non-utf8 better in wpt logging. r=maja_zf, a=test-only
authorJames Graham <james@hoppipolla.co.uk>
Tue, 24 Oct 2017 18:30:05 +0100
changeset 432746 119fd95b6e842a6cba502cf849fddfe558ee38bc
parent 432745 036b6ffa94c9852463c0726ce70ac79a6f65427e
child 432747 df3cc0ef0e479d928dc4d1e75bdd81089fe109af
push id8050
push userryanvm@gmail.com
push dateWed, 25 Oct 2017 18:39:16 +0000
treeherdermozilla-beta@921ae95a11f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, test-only
bugs1404733
milestone57.0
Bug 1404733 - Handle non-utf8 better in wpt logging. r=maja_zf, a=test-only MozReview-Commit-ID: GMofBbKUtt0
testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
@@ -71,17 +71,20 @@ class LoggingWrapper(StringIO):
 
     def __init__(self, queue, prefix=None):
         StringIO.__init__(self)
         self.queue = queue
         self.prefix = prefix
 
     def write(self, data):
         if isinstance(data, str):
-            data = data.decode("utf8")
+            try:
+                data = data.decode("utf8")
+            except UnicodeDecodeError:
+                data = data.encode("string_escape").decode("ascii")
 
         if data.endswith("\n"):
             data = data[:-1]
         if data.endswith("\r"):
             data = data[:-1]
         if not data:
             return
         if self.prefix is not None: