<div dir="ltr">LGTM</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 23, 2014 at 12:50 AM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi ddunbar,<br>
<br>
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.<br>
<br>
REPOSITORY<br>
rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D6769" target="_blank">http://reviews.llvm.org/D6769</a><br>
<br>
Files:<br>
utils/lit/lit/util.py<br>
<br>
Index: utils/lit/lit/util.py<br>
===================================================================<br>
--- utils/lit/lit/util.py<br>
+++ utils/lit/lit/util.py<br>
@@ -16,6 +16,12 @@<br>
return bytes<br>
return to_bytes(bytes)<br>
<br>
+def convert_string(bytes):<br>
+ try:<br>
+ return to_string(bytes.decode('utf-8'))<br>
+ except UnicodeError:<br>
+ return str(bytes)<br>
+<br>
def detectCPUs():<br>
"""<br>
Detects the number of CPUs on a system. Cribbed from pp.<br>
@@ -60,7 +66,7 @@<br>
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,<br>
env=env)<br>
out,_ = p.communicate()<br>
- return out<br>
+ return convert_string(out)<br>
<br>
def which(command, paths = None):<br>
"""which(command, [paths]) - Look up the given command in the paths string<br>
@@ -166,14 +172,8 @@<br>
raise KeyboardInterrupt<br>
<br>
# Ensure the resulting output is always of string type.<br>
- try:<br>
- out = to_string(out.decode('utf-8'))<br>
- except:<br>
- out = str(out)<br>
- try:<br>
- err = to_string(err.decode('utf-8'))<br>
- except:<br>
- err = str(err)<br>
+ out = convert_string(out)<br>
+ err = convert_string(err)<br>
<br>
return out, err, exitCode<br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div><br></div>