Python 2/3 compat: StringIO

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

llvm-svn: 356910
This commit is contained in:
Serge Guelton 2019-03-25 15:23:34 +00:00
parent 6ee3804613
commit 3a22c3cc2b
8 changed files with 18 additions and 21 deletions

View File

@ -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):

View File

@ -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" %

View File

@ -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

View File

@ -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_symbol):
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_buffer=False):
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, showFuncName=True):
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(BasicFormatter):
def format(self, value, buffer=None):
if not buffer:
output = StringIO.StringIO()
output = io.StringIO()
else:
output = buffer
@ -1019,7 +1019,7 @@ class RecursiveDecentFormatter(BasicFormatter):
def format(self, value, buffer=None):
if not buffer:
output = StringIO.StringIO()
output = io.StringIO()
else:
output = buffer

View File

@ -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):

View File

@ -11,7 +11,7 @@ and multiple OS types, verifying changes across all.
"""
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):

View File

@ -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\) "

View File

@ -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