llvm.org GIT mirror llvm / 2d88dc2
[LIT] Decode string result in lit.util.capture Summary: I think this is probably a bug, but I'm putting this up for review just to be sure. I think that `lit.util.capture` should decode the resulting string in the same way `lit.util.executeCommand` does. Reviewers: ddunbar, EricWF Reviewed By: EricWF Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6769 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225681 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Fiselier 4 years ago
1 changed file(s) with 9 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1414 if isinstance(bytes, str):
1515 return bytes
1616 return to_bytes(bytes)
17
18 def convert_string(bytes):
19 try:
20 return to_string(bytes.decode('utf-8'))
21 except UnicodeError:
22 return str(bytes)
1723
1824 def detectCPUs():
1925 """
5965 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
6066 env=env)
6167 out,_ = p.communicate()
62 return out
68 return convert_string(out)
6369
6470 def which(command, paths = None):
6571 """which(command, [paths]) - Look up the given command in the paths string
165171 raise KeyboardInterrupt
166172
167173 # Ensure the resulting output is always of string type.
168 try:
169 out = to_string(out.decode('utf-8'))
170 except:
171 out = str(out)
172 try:
173 err = to_string(err.decode('utf-8'))
174 except:
175 err = str(err)
174 out = convert_string(out)
175 err = convert_string(err)
176176
177177 return out, err, exitCode
178178