Skip to content

Commit

Permalink
[lldb/Test] Decode stdout and stderr in case it contains Unicode.
Browse files Browse the repository at this point in the history
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

(cherry picked from commit 2de5242)
  • Loading branch information
JDevlieghere committed Apr 21, 2020
1 parent b7867f6 commit 87b6ab2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lldb/test/API/lldbtest.py
Expand Up @@ -99,6 +99,11 @@ def execute(self, test, litConfig):
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:
Expand Down

0 comments on commit 87b6ab2

Please sign in to comment.