Use universal_newlines=True in subprocess.check_output.

In python 3, subprocess uses bytes for input and output if
universal_newlines=False (the default).  It uses str for input and
output if universal_newlines=True.

Since we mostly deal with strings, add universal_newlines=True to
subprocess.check_output.
This commit is contained in:
Eklavya Sharma 2016-07-26 09:46:55 +05:30 committed by Tim Abbott
parent 5ce80eb4ba
commit e0dbaf1031
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import sys
def test_cmd(cmd):
try:
return subprocess.check_output([__file__] + cmd.split(' '))
return subprocess.check_output([__file__] + cmd.split(' '), universal_newlines=True)
except subprocess.CalledProcessError as err:
sys.stderr.write('FAIL: %s\n' % ' '.join(err.cmd))
sys.stderr.write(' %s\n' % err.output)

View File

@ -87,7 +87,7 @@ def json_report_error(request, user_profile, message=REQ(), stacktrace=REQ(),
stacktrace = js_source_map.annotate_stacktrace(stacktrace)
try:
version = subprocess.check_output(["git", "log", "HEAD^..HEAD", "--oneline"])
version = subprocess.check_output(["git", "log", "HEAD^..HEAD", "--oneline"], universal_newlines=True)
except Exception:
version = None