From bbc5b46a106b24a3e559dade0fe25729a515c6c4 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 4 Nov 2015 01:03:47 +0000 Subject: 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 --- lldb/packages/Python/lldbsuite/support/seven.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lldb/packages/Python/lldbsuite/support/seven.py') 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) -- cgit v1.2.3