From 2de52422acf04662b45599f77c14ce1b2cec2b81 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 21 Apr 2020 08:25:44 -0700 Subject: [PATCH] [lldb/Test] Decode stdout and stderr in case it contains Unicode. Lit's to_string will just return the string when it's a `str` instance, which in Python 2 can still contain UTF-8 characters. Differential revision: https://reviews.llvm.org/D76955 --- lldb/test/API/lldbtest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py index 0831af677829..dc108462c8a8 100644 --- a/lldb/test/API/lldbtest.py +++ b/lldb/test/API/lldbtest.py @@ -110,6 +110,11 @@ class LLDBTest(TestFormat): timeoutInfo = 'Reached timeout of {} seconds'.format( litConfig.maxIndividualTestTime) + if sys.version_info.major == 2: + # In Python 2, string objects can contain Unicode characters. + out = out.decode('utf-8') + err = err.decode('utf-8') + output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % ( ' '.join(cmd), exitCode) if timeoutInfo is not None: