[Lldb-commits] [lldb] r356910 - Python 2/3 compat: StringIO

Serge Guelton via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 25 08:23:35 PDT 2019


Author: serge_sans_paille
Date: Mon Mar 25 08:23:34 2019
New Revision: 356910

URL: http://llvm.org/viewvc/llvm-project?rev=356910&view=rev
Log:
Python 2/3 compat: StringIO

Differential Revision: https://reviews.llvm.org/D59582

Modified:
    lldb/trunk/examples/customization/bin-utils/binutils.py
    lldb/trunk/examples/python/mach_o.py
    lldb/trunk/utils/git-svn/convert.py
    lldb/trunk/utils/lui/lldbutil.py
    lldb/trunk/utils/misc/grep-svn-log.py
    lldb/trunk/utils/sync-source/syncsource.py
    lldb/trunk/utils/test/disasm.py
    lldb/trunk/utils/test/run-until-faulted.py

Modified: lldb/trunk/examples/customization/bin-utils/binutils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/customization/bin-utils/binutils.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/examples/customization/bin-utils/binutils.py (original)
+++ lldb/trunk/examples/customization/bin-utils/binutils.py Mon Mar 25 08:23:34 2019
@@ -1,7 +1,5 @@
 "Collection of tools for displaying bit representation of numbers."""
 
-import StringIO
-
 from __future__ import print_function
 
 def binary(n, width=None):

Modified: lldb/trunk/examples/python/mach_o.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/mach_o.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/examples/python/mach_o.py (original)
+++ lldb/trunk/examples/python/mach_o.py Mon Mar 25 08:23:34 2019
@@ -8,7 +8,7 @@ import optparse
 import re
 import struct
 import string
-import StringIO
+import io
 import sys
 import uuid
 
@@ -1054,7 +1054,7 @@ class Mach:
                             if options.extract_modules:
                                 # print "Extracting modules from mach file..."
                                 data = file_extract.FileExtract(
-                                    StringIO.StringIO(sect_bytes), self.data.byte_order)
+                                    io.BytesIO(sect_bytes), self.data.byte_order)
                                 version = data.get_uint32()
                                 num_modules = data.get_uint32()
                                 # print "version = %u, num_modules = %u" %

Modified: lldb/trunk/utils/git-svn/convert.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/git-svn/convert.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/git-svn/convert.py (original)
+++ lldb/trunk/utils/git-svn/convert.py Mon Mar 25 08:23:34 2019
@@ -16,7 +16,7 @@ from __future__ import print_function
 import os
 import re
 import sys
-import StringIO
+import io
 
 
 def usage(problem_file=None):
@@ -37,7 +37,7 @@ def do_convert(file):
         content = f_in.read()
 
     # The new content to be written back to the same file.
-    new_content = StringIO.StringIO()
+    new_content = io.StringIO()
 
     # Boolean flag controls whether to start printing lines.
     from_header_seen = False

Modified: lldb/trunk/utils/lui/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/lui/lldbutil.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/lui/lldbutil.py (original)
+++ lldb/trunk/utils/lui/lldbutil.py Mon Mar 25 08:23:34 2019
@@ -17,7 +17,7 @@ from __future__ import print_function
 import lldb
 import os
 import sys
-import StringIO
+import io
 
 # ===================================================
 # Utilities for locating/checking executable programs
@@ -52,7 +52,7 @@ def disassemble(target, function_or_symb
 
     It returns the disassembly content in a string object.
     """
-    buf = StringIO.StringIO()
+    buf = io.StringIO()
     insts = function_or_symbol.GetInstructions(target)
     for i in insts:
         print(i, file=buf)
@@ -776,7 +776,7 @@ def get_stack_frames(thread):
 def print_stacktrace(thread, string_buffer=False):
     """Prints a simple stack trace of this thread."""
 
-    output = StringIO.StringIO() if string_buffer else sys.stdout
+    output = io.StringIO() if string_buffer else sys.stdout
     target = thread.GetProcess().GetTarget()
 
     depth = thread.GetNumFrames()
@@ -819,7 +819,7 @@ def print_stacktrace(thread, string_buff
 def print_stacktraces(process, string_buffer=False):
     """Prints the stack traces of all the threads."""
 
-    output = StringIO.StringIO() if string_buffer else sys.stdout
+    output = io.StringIO() if string_buffer else sys.stdout
 
     print("Stack traces for " + str(process), file=output)
 
@@ -879,7 +879,7 @@ def get_args_as_string(frame, showFuncNa
 def print_registers(frame, string_buffer=False):
     """Prints all the register sets of the frame."""
 
-    output = StringIO.StringIO() if string_buffer else sys.stdout
+    output = io.StringIO() if string_buffer else sys.stdout
 
     print("Register sets for " + str(frame), file=output)
 
@@ -962,7 +962,7 @@ class BasicFormatter(object):
 
     def format(self, value, buffer=None, indent=0):
         if not buffer:
-            output = StringIO.StringIO()
+            output = io.StringIO()
         else:
             output = buffer
         # If there is a summary, it suffices.
@@ -992,7 +992,7 @@ class ChildVisitingFormatter(BasicFormat
 
     def format(self, value, buffer=None):
         if not buffer:
-            output = StringIO.StringIO()
+            output = io.StringIO()
         else:
             output = buffer
 
@@ -1019,7 +1019,7 @@ class RecursiveDecentFormatter(BasicForm
 
     def format(self, value, buffer=None):
         if not buffer:
-            output = StringIO.StringIO()
+            output = io.StringIO()
         else:
             output = buffer
 

Modified: lldb/trunk/utils/misc/grep-svn-log.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/misc/grep-svn-log.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/misc/grep-svn-log.py (original)
+++ lldb/trunk/utils/misc/grep-svn-log.py Mon Mar 25 08:23:34 2019
@@ -13,7 +13,7 @@ from __future__ import print_function
 import fileinput
 import re
 import sys
-import StringIO
+import io
 
 # Separator string for "svn log -v" output.
 separator = '-' * 72
@@ -23,7 +23,7 @@ Example:
     svn log -v | grep-svn-log.py '^   D.+why_are_you_missing.h'"""
 
 
-class Log(StringIO.StringIO):
+class Log(io.StringIO):
     """Simple facade to keep track of the log content."""
 
     def __init__(self):

Modified: lldb/trunk/utils/sync-source/syncsource.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/sync-source/syncsource.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/sync-source/syncsource.py (original)
+++ lldb/trunk/utils/sync-source/syncsource.py Mon Mar 25 08:23:34 2019
@@ -11,7 +11,7 @@ and multiple OS types, verifying changes
 """
 
 import argparse
-import cStringIO
+import io
 import importlib
 import json
 import os.path
@@ -89,11 +89,11 @@ def read_rcfile(filename):
     # preserving the line count.
     regex = re.compile(r"#.*$")
 
-    comment_stripped_file = cStringIO.StringIO()
+    comment_stripped_file = io.StringIO()
     with open(filename, "r") as json_file:
         for line in json_file:
             comment_stripped_file.write(regex.sub("", line))
-    return json.load(cStringIO.StringIO(comment_stripped_file.getvalue()))
+    return json.load(io.StringIO(comment_stripped_file.getvalue()))
 
 
 def find_appropriate_rcfile(options):

Modified: lldb/trunk/utils/test/disasm.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/disasm.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/test/disasm.py (original)
+++ lldb/trunk/utils/test/disasm.py Mon Mar 25 08:23:34 2019
@@ -39,7 +39,7 @@ def do_llvm_mc_disassembly(
         func,
         mc,
         mc_options):
-    from cStringIO import StringIO
+    from io import StringIO
     import pexpect
 
     gdb_prompt = "\r\n\(gdb\) "

Modified: lldb/trunk/utils/test/run-until-faulted.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-until-faulted.py?rev=356910&r1=356909&r2=356910&view=diff
==============================================================================
--- lldb/trunk/utils/test/run-until-faulted.py (original)
+++ lldb/trunk/utils/test/run-until-faulted.py Mon Mar 25 08:23:34 2019
@@ -32,7 +32,6 @@ def which(program):
 
 
 def do_lldb_launch_loop(lldb_command, exe, exe_options):
-    from cStringIO import StringIO
     import pexpect
     import time
 




More information about the lldb-commits mailing list