[Lldb-commits] [PATCH] D63311: Python 3: decode string as utf-8 to avoid type mismatch.

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 14 08:31:48 PDT 2019


aprantl updated this revision to Diff 204772.
aprantl added a comment.

Address review feedback.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63311/new/

https://reviews.llvm.org/D63311

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -58,7 +58,7 @@
     platform_system = platform.system()
     if platform_system == 'Darwin':
         # On Darwin, try the currently selected Xcode directory
-        xcode_dir = subprocess.check_output("xcode-select --print-path", shell=True)
+        xcode_dir = subprocess.check_output("xcode-select --print-path", shell=True).decode("utf-8")
         if xcode_dir:
             lldb_python_dirs.append(
                 os.path.realpath(
@@ -232,7 +232,7 @@
         if not os.path.exists(dsymForUUIDBinary):
             try:
                 dsymForUUIDBinary = subprocess.check_output('which dsymForUUID',
-                                                            shell=True).rstrip('\n')
+                                                            shell=True).decode("utf-8").rstrip('\n')
             except:
                 dsymForUUIDBinary = ""
 
@@ -300,7 +300,7 @@
             if os.path.exists(self.dsymForUUIDBinary):
                 dsym_for_uuid_command = '%s %s' % (
                     self.dsymForUUIDBinary, uuid_str)
-                s = subprocess.check_output(dsym_for_uuid_command, shell=True)
+                s = subprocess.check_output(dsym_for_uuid_command, shell=True).decode("utf-8")
                 if s:
                     try:
                         plist_root = read_plist(s)
@@ -326,7 +326,7 @@
                 try:
                     dsym = subprocess.check_output(
                         ["/usr/bin/mdfind",
-                         "com_apple_xcode_dsym_uuids == %s"%uuid_str])[:-1]
+                         "com_apple_xcode_dsym_uuids == %s"%uuid_str]).decode("utf-8")[:-1]
                     if dsym and os.path.exists(dsym):
                         print(('falling back to binary inside "%s"'%dsym))
                         self.symfile = dsym
@@ -764,7 +764,7 @@
                        (datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
         out_file.write(
             'OS Version:      Mac OS X %s (%s)\n' %
-            (platform.mac_ver()[0], subprocess.check_output('sysctl -n kern.osversion', shell=True)))
+            (platform.mac_ver()[0], subprocess.check_output('sysctl -n kern.osversion', shell=True).decode("utf-8")))
         out_file.write('Report Version:  9\n')
         for thread_idx in range(process.num_threads):
             thread = process.thread[thread_idx]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63311.204772.patch
Type: text/x-patch
Size: 2549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190614/b56608ea/attachment-0001.bin>


More information about the lldb-commits mailing list