From e0dbaf1031483b33880653e29a4c8d3147f4f2d0 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Tue, 26 Jul 2016 09:46:55 +0530 Subject: [PATCH] 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. --- frontend_tests/casperjs/bin/casperjs | 2 +- zerver/views/report.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend_tests/casperjs/bin/casperjs b/frontend_tests/casperjs/bin/casperjs index cb383372c1..335b90dd12 100755 --- a/frontend_tests/casperjs/bin/casperjs +++ b/frontend_tests/casperjs/bin/casperjs @@ -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) diff --git a/zerver/views/report.py b/zerver/views/report.py index 88fecab4cf..797cfd97dd 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -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