Author: zturner Date: Tue Nov 3 19:03:47 2015 New Revision: 252025 URL: http://llvm.org/viewvc/llvm-project?rev=252025&view=rev Log: 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. Modified: lldb/trunk/packages/Python/lldbsuite/support/seven.py lldb/trunk/packages/Python/lldbsuite/test/dotest.py Modified: lldb/trunk/packages/Python/lldbsuite/support/seven.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/support/seven.py?rev=252025&r1=252024&r2=252025&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/support/seven.py (original) +++ lldb/trunk/packages/Python/lldbsuite/support/seven.py Tue Nov 3 19:03:47 2015 @@ -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) Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=252025&r1=252024&r2=252025&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Tue Nov 3 19:03:47 2015 @@ -1147,7 +1147,7 @@ def setupSysPath(): # If our lldb supports the -P option, use it to find the python path: init_in_python_dir = os.path.join('lldb', '__init__.py') - lldb_dash_p_result = subprocess.check_output([lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT) + lldb_dash_p_result = subprocess.check_output([lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT, universal_newlines=True) if lldb_dash_p_result and not lldb_dash_p_result.startswith(("<", "lldb: invalid option:")) \ and not lldb_dash_p_result.startswith("Traceback"): _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits