diff options
author | Zachary Turner <zturner@google.com> | 2015-11-04 01:03:47 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-04 01:03:47 +0000 |
commit | bbc5b46a106b24a3e559dade0fe25729a515c6c4 (patch) | |
tree | d420578322457b2c2f4df0f0b1462f4a93007448 /lldb/packages/Python/lldbsuite/support/seven.py | |
parent | 1c58d5ac9003a772d2a290f9758ed45a3f0aa53a (diff) | |
download | bcm5719-llvm-bbc5b46a106b24a3e559dade0fe25729a515c6c4.tar.gz bcm5719-llvm-bbc5b46a106b24a3e559dade0fe25729a515c6c4.zip |
Python 3 - Use universal_newlines when calling subprocess.check_output
By default in Python 3, check_output() returns a program's output as
an encoded byte sequence. This means it returns a Py3 `bytes` object,
which cannot be compared to a string since it's a different fundamental
type.
Although it might not be correct from a purist standpoint, from a
practical one we can assume that all output is encoded in the default
locale, in which case using universal_newlines=True will decode it
according to the current locale. Anyway, universal_newlines also
has the nice behavior that it converts \r\n to \n on Windows platforms
so this makes parsing code easier, should we need that. So it seems
like a win/win.
llvm-svn: 252025
Diffstat (limited to 'lldb/packages/Python/lldbsuite/support/seven.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/support/seven.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lldb/packages/Python/lldbsuite/support/seven.py b/lldb/packages/Python/lldbsuite/support/seven.py index 29c6e9e1353..56ddd8db3f6 100644 --- a/lldb/packages/Python/lldbsuite/support/seven.py +++ b/lldb/packages/Python/lldbsuite/support/seven.py @@ -10,7 +10,7 @@ else: def get_command_status_output(command): try: import subprocess - return (0, subprocess.check_output(command, shell=True)) + return (0, subprocess.check_output(command, shell=True, universal_newlines=True)) except subprocess.CalledProcessError as e: return (e.returncode, e.output) |