From 7db492c7963308ba8b594a80d752c9c600772824 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 24 Oct 2017 18:30:05 +0100 Subject: [PATCH] Bug 1404733 - Handle non-utf8 better in wpt logging, r=maja_zf MozReview-Commit-ID: GMofBbKUtt0 --HG-- extra : rebase_source : 0caf26492e484032230824cbb20666577a6eeae7 --- .../tests/tools/wptrunner/wptrunner/wptlogging.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py index 1ab6755c4352..4d320617859c 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py @@ -76,7 +76,10 @@ class LoggingWrapper(StringIO): 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]