[Lldb-commits] [lldb] r258588 - Decode files with UTF-8 in lldbutil.line_number.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 22 15:54:50 PST 2016


Author: zturner
Date: Fri Jan 22 17:54:49 2016
New Revision: 258588

URL: http://llvm.org/viewvc/llvm-project?rev=258588&view=rev
Log:
Decode files with UTF-8 in lldbutil.line_number.

Since Unicode support is different in Py2 and Py3, Py3 was throwing
exceptions about being unable to decode the file with the default
encoding.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=258588&r1=258587&r2=258588&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Fri Jan 22 17:54:49 2016
@@ -41,6 +41,7 @@ from distutils.version import LooseVersi
 import gc
 import glob
 import inspect
+import io
 import os, sys, traceback
 import os.path
 import re
@@ -201,7 +202,7 @@ def EnvArray():
 
 def line_number(filename, string_to_match):
     """Helper function to return the line number of the first matched string."""
-    with open(filename, 'r') as f:
+    with io.open(filename, mode='r', encoding="utf-8") as f:
         for i, line in enumerate(f):
             if line.find(string_to_match) != -1:
                 # Found our match.




More information about the lldb-commits mailing list