[lit] Parse all strings as UTF-8 rather than ASCII.

As far as I can tell UTF-8 has been supported since the beginning of Python's
codec support, and it's the de facto standard for text these days, at least
for primarily-English text. This allows us to put Unicode into lit RUN lines.

rdar://problem/18311663

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jordan Rose
2014-09-12 16:46:05 +00:00
parent 81d53b7290
commit c919e57cbf
5 changed files with 33 additions and 15 deletions

View File

@@ -156,13 +156,18 @@ def executeCommand(command, cwd=None, env=None):
if exitCode == -signal.SIGINT:
raise KeyboardInterrupt
def to_string(bytes):
if isinstance(bytes, str):
return bytes
return bytes.encode('utf-8')
# Ensure the resulting output is always of string type.
try:
out = str(out.decode('ascii'))
out = to_string(out.decode('utf-8'))
except:
out = str(out)
try:
err = str(err.decode('ascii'))
err = to_string(err.decode('utf-8'))
except:
err = str(err)