kastiglione updated this revision to Diff 452007.
kastiglione added a comment.
Restore LLDB_USE_SYSTEM_SIX
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131304/new/
https://reviews.llvm.org/D131304
Files:
lldb/bindings/interface/SBData.i
lldb/bindings/python/python.swig
lldb/examples/python/scripted_process/scripted_process.py
lldb/examples/summaries/synth.py
lldb/packages/Python/lldbsuite/support/encoded_file.py
lldb/packages/Python/lldbsuite/support/seven.py
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/lldbpexpect.py
lldb/packages/Python/lldbsuite/test/lldbplatform.py
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/test/API/api/listeners/TestListener.py
lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
lldb/test/API/commands/process/launch/TestProcessLaunch.py
lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
lldb/test/API/python_api/frame/TestFrames.py
lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
lldb/test/API/test_utils/base/TestBaseTest.py
lldb/third_party/Python/module/progress/progress.py
lldb/third_party/Python/module/unittest2/unittest2/case.py
lldb/third_party/Python/module/unittest2/unittest2/main.py
lldb/third_party/Python/module/unittest2/unittest2/result.py
lldb/third_party/Python/module/unittest2/unittest2/suite.py
lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
@@ -1,5 +1,4 @@
import unittest2
-import six
from unittest2.test.support import LoggingResult
@@ -125,7 +124,7 @@
def test_id(self):
test = unittest2.FunctionTestCase(lambda: None)
- self.assertIsInstance(test.id(), six.string_types)
+ self.assertIsInstance(test.id(), str)
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
@@ -1,7 +1,6 @@
import difflib
import pprint
import re
-import six
from copy import deepcopy
@@ -543,7 +542,7 @@
def runTest(self):
pass
- self.assertIsInstance(Foo().id(), six.string_types)
+ self.assertIsInstance(Foo().id(), str)
# "If result is omitted or None, a temporary result object is created
# and used, but is not made available to the caller. As TestCase owns the
Index: lldb/third_party/Python/module/unittest2/unittest2/suite.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/suite.py
+++ lldb/third_party/Python/module/unittest2/unittest2/suite.py
@@ -3,7 +3,6 @@
import sys
import unittest
from unittest2 import case, util
-import six
__unittest = True
@@ -50,7 +49,7 @@
self._tests.append(test)
def addTests(self, tests):
- if isinstance(tests, six.string_types):
+ if isinstance(tests, str):
raise TypeError("tests must be an iterable of tests, not a string")
for test in tests:
self.addTest(test)
Index: lldb/third_party/Python/module/unittest2/unittest2/result.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/result.py
+++ lldb/third_party/Python/module/unittest2/unittest2/result.py
@@ -2,12 +2,11 @@
import use_lldb_suite
+import io
import sys
import traceback
import unittest
-from six import StringIO as SixStringIO
-
from unittest2 import util
from unittest2.compatibility import wraps
@@ -65,8 +64,8 @@
self._mirrorOutput = False
if self.buffer:
if self._stderr_buffer is None:
- self._stderr_buffer = SixStringIO()
- self._stdout_buffer = SixStringIO()
+ self._stderr_buffer = io.StringIO()
+ self._stdout_buffer = io.StringIO()
sys.stdout = self._stdout_buffer
sys.stderr = self._stderr_buffer
Index: lldb/third_party/Python/module/unittest2/unittest2/main.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/main.py
+++ lldb/third_party/Python/module/unittest2/unittest2/main.py
@@ -3,7 +3,6 @@
import sys
import os
import types
-import six
from unittest2 import loader, runner
try:
@@ -77,7 +76,7 @@
argv=None, testRunner=None,
testLoader=loader.defaultTestLoader, exit=True,
verbosity=1, failfast=None, catchbreak=None, buffer=None):
- if isinstance(module, six.string_types):
+ if isinstance(module, str):
self.module = __import__(module)
for part in module.split('.')[1:]:
self.module = getattr(self.module, part)
Index: lldb/third_party/Python/module/unittest2/unittest2/case.py
===================================================================
--- lldb/third_party/Python/module/unittest2/unittest2/case.py
+++ lldb/third_party/Python/module/unittest2/unittest2/case.py
@@ -7,8 +7,6 @@
import unittest
import warnings
-import six
-
from unittest2 import result
from unittest2.util import (
safe_repr, safe_str, strclass,
@@ -153,7 +151,7 @@
return True
expected_regexp = self.expected_regexp
- if isinstance(expected_regexp, six.string_types):
+ if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(str(exc_value)):
raise self.failureException(
@@ -173,7 +171,7 @@
def __getitem__(self, key):
value = self._store[key]
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
return getattr(self.testcase, value)
return value
@@ -251,10 +249,7 @@
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
self.addTypeEqualityFunc(set, 'assertSetEqual')
self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
- if six.PY2:
- self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
- else:
- self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
+ self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
def addTypeEqualityFunc(self, typeobj, function):
"""Add a type specific assertEqual style function to compare a type.
@@ -993,9 +988,9 @@
def assertMultiLineEqual(self, first, second, msg=None):
"""Assert that two multi-line strings are equal."""
- self.assert_(isinstance(first, six.string_types), (
+ self.assert_(isinstance(first, str), (
'First argument is not a string'))
- self.assert_(isinstance(second, six.string_types), (
+ self.assert_(isinstance(second, str), (
'Second argument is not a string'))
if first != second:
@@ -1076,7 +1071,7 @@
try:
callable_obj(*args, **kwargs)
except expected_exception as exc_value:
- if isinstance(expected_regexp, six.string_types):
+ if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(str(exc_value)):
raise self.failureException(
@@ -1091,7 +1086,7 @@
def assertRegexpMatches(self, text, expected_regexp, msg=None):
"""Fail the test unless the text matches the regular expression."""
- if isinstance(expected_regexp, six.string_types):
+ if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text):
msg = msg or "Regexp didn't match"
@@ -1101,7 +1096,7 @@
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
"""Fail the test if the text matches the regular expression."""
- if isinstance(unexpected_regexp, six.string_types):
+ if isinstance(unexpected_regexp, str):
unexpected_regexp = re.compile(unexpected_regexp)
match = unexpected_regexp.search(text)
if match:
Index: lldb/third_party/Python/module/progress/progress.py
===================================================================
--- lldb/third_party/Python/module/progress/progress.py
+++ lldb/third_party/Python/module/progress/progress.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
import use_lldb_suite
-import six
import sys
import time
@@ -19,17 +18,17 @@
format Format
incremental
"""
- light_block = six.unichr(0x2591).encode("utf-8")
- solid_block = six.unichr(0x2588).encode("utf-8")
- solid_right_arrow = six.unichr(0x25BA).encode("utf-8")
+ light_block = chr(0x2591).encode("utf-8")
+ solid_block = chr(0x2588).encode("utf-8")
+ solid_right_arrow = chr(0x25BA).encode("utf-8")
def __init__(self,
start=0,
end=10,
width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
+ fill=chr(0x25C9).encode("utf-8"),
+ blank=chr(0x25CC).encode("utf-8"),
+ marker=chr(0x25CE).encode("utf-8"),
format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True):
super(ProgressBar, self).__init__()
@@ -89,9 +88,9 @@
start=0,
end=10,
width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
+ fill=chr(0x25C9).encode("utf-8"),
+ blank=chr(0x25CC).encode("utf-8"),
+ marker=chr(0x25CE).encode("utf-8"),
format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True,
stdout=sys.stdout):
@@ -127,9 +126,9 @@
start=0,
end=10,
width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
+ fill=chr(0x25C9).encode("utf-8"),
+ blank=chr(0x25CC).encode("utf-8"),
+ marker=chr(0x25CE).encode("utf-8"),
format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
incremental=True,
stdout=sys.stdout):
Index: lldb/test/API/test_utils/base/TestBaseTest.py
===================================================================
--- lldb/test/API/test_utils/base/TestBaseTest.py
+++ lldb/test/API/test_utils/base/TestBaseTest.py
@@ -2,9 +2,10 @@
Test TestBase test functions.
"""
+import io
+
from lldbsuite.test.lldbtest import *
from lldbsuite.test_event import build_exception
-import six
class TestBuildMethod(Base):
@@ -15,9 +16,9 @@
# override the parent trace method
def trace(self, *args, **kwargs):
- io = six.StringIO()
- print(*args, file=io, **kwargs)
- self._traces.append(io.getvalue())
+ buf = io.StringIO()
+ print(*args, file=buf, **kwargs)
+ self._traces.append(buf.getvalue())
def test_build_fails_helpfully(self):
try:
Index: lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
===================================================================
--- lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
+++ lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
@@ -3,7 +3,7 @@
"""
import lldb
-import six
+import io
import sys
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -54,8 +54,8 @@
child.expect(expect_prompt)
# Turn on loggings for input/output to/from the child.
- child.logfile_send = child_send1 = six.StringIO()
- child.logfile_read = child_read1 = six.StringIO()
+ child.logfile_send = child_send1 = io.StringIO()
+ child.logfile_read = child_read1 = io.StringIO()
child.sendline('stty -a')
child.expect(expect_prompt)
@@ -72,8 +72,8 @@
child.sendline('quit')
child.expect(expect_prompt)
- child.logfile_send = child_send2 = six.StringIO()
- child.logfile_read = child_read2 = six.StringIO()
+ child.logfile_send = child_send2 = io.StringIO()
+ child.logfile_read = child_read2 = io.StringIO()
child.sendline('stty -a')
child.expect(expect_prompt)
Index: lldb/test/API/python_api/frame/TestFrames.py
===================================================================
--- lldb/test/API/python_api/frame/TestFrames.py
+++ lldb/test/API/python_api/frame/TestFrames.py
@@ -3,6 +3,8 @@
And other SBFrame API tests.
"""
+import io
+
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -39,8 +41,7 @@
# depth of 3 of the 'c' leaf function.
callsOfA = 0
- from six import StringIO as SixStringIO
- session = SixStringIO()
+ session = io.StringIO()
while process.GetState() == lldb.eStateStopped:
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
Index: lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
===================================================================
--- lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
+++ lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
@@ -7,9 +7,6 @@
get the 32-bit register contexts.
"""
-from six import iteritems
-
-
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
Index: lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
===================================================================
--- lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
+++ lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
@@ -2,9 +2,6 @@
Test basics of mini dump debugging.
"""
-from six import iteritems
-
-
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -130,7 +127,7 @@
expected_stack = {0: 'bar', 1: 'foo', 2: 'main'}
self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
- for index, name in iteritems(expected_stack):
+ for index, name in expected_stack.items():
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
===================================================================
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -2,9 +2,6 @@
Test basics of Minidump debugging.
"""
-from six import iteritems
-
-
import lldb
import os
from lldbsuite.test.decorators import *
Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===================================================================
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -2,8 +2,6 @@
Test basics of Minidump debugging.
"""
-from six import iteritems
-
import shutil
import lldb
@@ -327,7 +325,7 @@
expected_stack = {1: 'bar', 2: 'foo', 3: '_start'}
self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
- for index, name in iteritems(expected_stack):
+ for index, name in expected_stack.items():
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
Index: lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
@@ -3,7 +3,6 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.gdbclientutils import *
from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
-from lldbsuite.support import seven
class MyResponder(MockGDBServerResponder):
"""
Index: lldb/test/API/commands/process/launch/TestProcessLaunch.py
===================================================================
--- lldb/test/API/commands/process/launch/TestProcessLaunch.py
+++ lldb/test/API/commands/process/launch/TestProcessLaunch.py
@@ -9,8 +9,6 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-import six
-
class ProcessLaunchTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
Index: lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
===================================================================
--- lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
+++ lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
@@ -1,7 +1,3 @@
-
-import six
-
-
def command(debugger, command, result, internal_dict):
- result.PutCString(six.u("hello world B"))
+ result.PutCString("hello world B")
return None
Index: lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
===================================================================
--- lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
+++ lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
@@ -1,7 +1,3 @@
-
-import six
-
-
def command(debugger, command, result, internal_dict):
- result.PutCString(six.u("hello world A"))
+ result.PutCString("hello world A")
return None
Index: lldb/test/API/api/listeners/TestListener.py
===================================================================
--- lldb/test/API/api/listeners/TestListener.py
+++ lldb/test/API/api/listeners/TestListener.py
@@ -7,8 +7,6 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-import six
-
class ListenToModuleLoadedEvents (TestBase):
NO_DEBUG_INFO_TESTCASE = True
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -429,7 +429,7 @@
// Reloading modules requires a different syntax in Python 2 and Python 3.
// This provides a consistent syntax no matter what version of Python.
run_string.Clear();
- run_string.Printf("run_one_line (%s, 'from six.moves import reload_module')",
+ run_string.Printf("run_one_line (%s, 'from importlib import reload as reload_module')",
m_dictionary_name.c_str());
PyRun_SimpleString(run_string.GetData());
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -6,7 +6,6 @@
import os.path
import platform
import re
-import six
import socket
import subprocess
from lldbsuite.support import seven
@@ -801,7 +800,7 @@
If we don't know how to check running process ids on the given OS:
return the value provided by the unknown_value arg.
"""
- if not isinstance(pid, six.integer_types):
+ if not isinstance(pid, int):
raise Exception(
"pid must be an integral type (actual type: %s)" % str(
type(pid)))
@@ -876,7 +875,7 @@
@staticmethod
def _checksum(packet):
checksum = 0
- for c in six.iterbytes(packet):
+ for c in iter(packet):
checksum += c
return checksum % 256
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -56,8 +56,7 @@
return super(GdbRemoteTestCaseFactory, cls).__new__(
cls, name, bases, newattrs)
-@add_metaclass(GdbRemoteTestCaseFactory)
-class GdbRemoteTestCaseBase(Base):
+class GdbRemoteTestCaseBase(Base, metaclass=GdbRemoteTestCaseFactory):
# Default time out in seconds. The timeout is increased tenfold under Asan.
DEFAULT_TIMEOUT = 20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
Index: lldb/packages/Python/lldbsuite/test/lldbutil.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -6,16 +6,13 @@
# System modules
import errno
+import io
import os
import re
import sys
import subprocess
from typing import Dict
-# Third-party modules
-from six import StringIO as SixStringIO
-import six
-
# LLDB modules
import lldb
from . import lldbtest_config
@@ -108,7 +105,7 @@
It returns the disassembly content in a string object.
"""
- buf = SixStringIO()
+ buf = io.StringIO()
insts = function_or_symbol.GetInstructions(target)
for i in insts:
print(i, file=buf)
@@ -1077,7 +1074,7 @@
def print_stacktrace(thread, string_buffer=False):
"""Prints a simple stack trace of this thread."""
- output = SixStringIO() if string_buffer else sys.stdout
+ output = io.StringIO() if string_buffer else sys.stdout
target = thread.GetProcess().GetTarget()
depth = thread.GetNumFrames()
@@ -1139,7 +1136,7 @@
def print_stacktraces(process, string_buffer=False):
"""Prints the stack traces of all the threads."""
- output = SixStringIO() if string_buffer else sys.stdout
+ output = io.StringIO() if string_buffer else sys.stdout
print("Stack traces for " + str(process), file=output)
@@ -1255,7 +1252,7 @@
def print_registers(frame, string_buffer=False):
"""Prints all the register sets of the frame."""
- output = SixStringIO() if string_buffer else sys.stdout
+ output = io.StringIO() if string_buffer else sys.stdout
print("Register sets for " + str(frame), file=output)
@@ -1341,7 +1338,7 @@
def format(self, value, buffer=None, indent=0):
if not buffer:
- output = SixStringIO()
+ output = io.StringIO()
else:
output = buffer
# If there is a summary, it suffices.
@@ -1371,7 +1368,7 @@
def format(self, value, buffer=None):
if not buffer:
- output = SixStringIO()
+ output = io.StringIO()
else:
output = buffer
@@ -1398,7 +1395,7 @@
def format(self, value, buffer=None):
if not buffer:
- output = SixStringIO()
+ output = io.StringIO()
else:
output = buffer
@@ -1508,7 +1505,7 @@
def skip_if_callable(test, mycallable, reason):
- if six.callable(mycallable):
+ if callable(mycallable):
if mycallable(test):
test.skipTest(reason)
return True
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,9 +45,6 @@
# Third-party modules
import unittest2
-from six import add_metaclass
-from six import StringIO as SixStringIO
-import six
# LLDB modules
import lldb
@@ -317,7 +314,7 @@
child_error = "Checking child with index " + str(i) + ":\n" + error_msg
expected_child.check_value(test_base, actual_child, child_error)
-class recording(SixStringIO):
+class recording(io.StringIO):
"""
A nice little context manager for recording the debugger interactions into
our session object. If trace flag is ON, it also emits the interactions
@@ -325,8 +322,8 @@
"""
def __init__(self, test, trace):
- """Create a SixStringIO instance; record the session obj and trace flag."""
- SixStringIO.__init__(self)
+ """Create a io.StringIO instance; record the session obj and trace flag."""
+ io.StringIO.__init__(self)
# The test might not have undergone the 'setUp(self)' phase yet, so that
# the attribute 'session' might not even exist yet.
self.session = getattr(test, "session", None) if test else None
@@ -335,7 +332,7 @@
def __enter__(self):
"""
Context management protocol on entry to the body of the with statement.
- Just return the SixStringIO object.
+ Just return the io.StringIO object.
"""
return self
@@ -343,7 +340,7 @@
"""
Context management protocol on exit from the body of the with statement.
If trace is ON, it emits the recordings into stderr. Always add the
- recordings to our session object. And close the SixStringIO object, too.
+ recordings to our session object. And close the io.StringIO object, too.
"""
if self.trace:
print(self.getvalue(), file=sys.stderr)
@@ -352,8 +349,7 @@
self.close()
-@add_metaclass(abc.ABCMeta)
-class _BaseProcess(object):
+class _BaseProcess(object, metaclass=abc.ABCMeta):
@abc.abstractproperty
def pid(self):
@@ -942,7 +938,7 @@
Hooks are executed in a first come first serve manner.
"""
- if six.callable(hook):
+ if callable(hook):
with recording(self, traceAlways) as sbuf:
print(
"Adding tearDown hook:",
@@ -1688,8 +1684,7 @@
# methods when a new class is loaded
-@add_metaclass(LLDBTestCaseFactory)
-class TestBase(Base):
+class TestBase(Base, metaclass=LLDBTestCaseFactory):
"""
This abstract base class is meant to be subclassed. It provides default
implementations for setUpClass(), tearDownClass(), setUp(), and tearDown(),
@@ -2227,7 +2222,7 @@
def expect(
self,
- str,
+ string,
msg=None,
patterns=None,
startstr=None,
@@ -2261,9 +2256,9 @@
client is expecting the output of the command not to match the golden
input.
- Finally, the required argument 'str' represents the lldb command to be
+ Finally, the required argument 'string' represents the lldb command to be
sent to the command interpreter. In case the keyword argument 'exe' is
- set to False, the 'str' is treated as a string to be matched/not-matched
+ set to False, the 'string' is treated as a string to be matched/not-matched
against the golden input.
"""
# Catch cases where `expect` has been miscalled. Specifically, prevent
@@ -2277,9 +2272,9 @@
assert False, "expect() missing a matcher argument"
# Check `patterns` and `substrs` are not accidentally given as strings.
- assert not isinstance(patterns, six.string_types), \
+ assert not isinstance(patterns, str), \
"patterns must be a collection of strings"
- assert not isinstance(substrs, six.string_types), \
+ assert not isinstance(substrs, str), \
"substrs must be a collection of strings"
trace = (True if traceAlways else trace)
@@ -2289,7 +2284,7 @@
# Pass the assert message along since it provides more semantic
# info.
self.runCmd(
- str,
+ string,
msg=msg,
trace=(
True if trace else False),
@@ -2302,13 +2297,13 @@
# If error is True, the API client expects the command to fail!
if error:
self.assertFalse(self.res.Succeeded(),
- "Command '" + str + "' is expected to fail!")
+ "Command '" + string + "' is expected to fail!")
else:
- # No execution required, just compare str against the golden input.
- if isinstance(str, lldb.SBCommandReturnObject):
- output = str.GetOutput()
+ # No execution required, just compare string against the golden input.
+ if isinstance(string, lldb.SBCommandReturnObject):
+ output = string.GetOutput()
else:
- output = str
+ output = string
with recording(self, trace) as sbuf:
print("looking at:", output, file=sbuf)
@@ -2319,7 +2314,7 @@
# To be used as assert fail message and/or trace content
log_lines = [
"{}:".format("Ran command" if exe else "Checking string"),
- "\"{}\"".format(str),
+ "\"{}\"".format(string),
# Space out command and output
"",
]
Index: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -7,10 +7,7 @@
import subprocess
import sys
import os
-
-# Third-party modules
-import six
-from six.moves.urllib import parse as urlparse
+from urllib.parse import urlparse
# LLDB modules
from . import configuration
@@ -60,7 +57,7 @@
if not hasattr(android_device_api, 'result'):
assert configuration.lldb_platform_url is not None
device_id = None
- parsed_url = urlparse.urlparse(configuration.lldb_platform_url)
+ parsed_url = urlparse(configuration.lldb_platform_url)
host_name = parsed_url.netloc.split(":")[0]
if host_name != 'localhost':
device_id = host_name
Index: lldb/packages/Python/lldbsuite/test/lldbplatform.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbplatform.py
+++ lldb/packages/Python/lldbsuite/test/lldbplatform.py
@@ -3,9 +3,6 @@
# System modules
import itertools
-# Third-party modules
-import six
-
# LLDB modules
import lldb
@@ -37,10 +34,10 @@
def translate(values):
- if isinstance(values, six.integer_types):
+ if isinstance(values, int):
# This is a value from the platform enumeration, translate it.
return __name_lookup[values]
- elif isinstance(values, six.string_types):
+ elif isinstance(values, str):
# This is a raw string, return it.
return [values]
elif hasattr(values, "__iter__"):
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -2,9 +2,6 @@
import os
import sys
-# Third-party modules
-import six
-
# LLDB Modules
import lldb
from .lldbtest import *
@@ -70,7 +67,7 @@
self.assertNotIn('\n', cmd)
# If 'substrs' is a string then this code would just check that every
# character of the string is in the output.
- assert not isinstance(substrs, six.string_types), \
+ assert not isinstance(substrs, str), \
"substrs must be a collection of strings"
self.child.sendline(cmd)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -33,7 +33,6 @@
import tempfile
# Third-party modules
-import six
import unittest2
# LLDB Modules
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -11,7 +11,6 @@
import subprocess
# Third-party modules
-import six
import unittest2
# LLDB modules
@@ -69,7 +68,6 @@
LooseVersion(expected_str))
-_re_pattern_type = type(re.compile(''))
def _match_decorator_property(expected, actual):
if expected is None:
return True
@@ -80,7 +78,7 @@
if isinstance(expected, no_match):
return not _match_decorator_property(expected.item, actual)
- if isinstance(expected, (_re_pattern_type,) + six.string_types):
+ if isinstance(expected, (re.Pattern, str)):
return re.search(expected, actual) is not None
if hasattr(expected, "__iter__"):
@@ -129,7 +127,7 @@
# the first way, the first argument will be the actual function because decorators are
# weird like that. So this is basically a check that says "which syntax was the original
# function decorated with?"
- if six.callable(bugnumber):
+ if callable(bugnumber):
return expectedFailure_impl(bugnumber)
else:
return expectedFailure_impl
@@ -160,7 +158,7 @@
# the first way, the first argument will be the actual function because decorators are
# weird like that. So this is basically a check that says "how was the
# decorator used"
- if six.callable(bugnumber):
+ if callable(bugnumber):
return skipTestIfFn_impl(bugnumber)
else:
return skipTestIfFn_impl
@@ -247,7 +245,7 @@
mode_str, reason_str)
else:
reason_str = "{} unconditionally"
- if bugnumber is not None and not six.callable(bugnumber):
+ if bugnumber is not None and not callable(bugnumber):
reason_str = reason_str + " [" + str(bugnumber) + "]"
return reason_str
@@ -461,7 +459,7 @@
# the first way, the first argument will be the actual function because decorators are
# weird like that. So this is basically a check that says "which syntax was the original
# function decorated with?"
- if six.callable(bugnumber):
+ if callable(bugnumber):
return expectedFailure_impl(bugnumber)
else:
return expectedFailure_impl
Index: lldb/packages/Python/lldbsuite/support/seven.py
===================================================================
--- lldb/packages/Python/lldbsuite/support/seven.py
+++ lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,47 +1,31 @@
import binascii
-import six
import shlex
+import subprocess
-if six.PY2:
- import commands
- get_command_output = commands.getoutput
- get_command_status_output = commands.getstatusoutput
+def get_command_output(command):
+ try:
+ return subprocess.check_output(
+ command,
+ shell=True,
+ universal_newlines=True).rstrip()
+ except subprocess.CalledProcessError as e:
+ return e.output
- cmp_ = cmp
-else:
- def get_command_status_output(command):
- try:
- import subprocess
- return (
- 0,
- subprocess.check_output(
- command,
- shell=True,
- universal_newlines=True).rstrip())
- except subprocess.CalledProcessError as e:
- return (e.returncode, e.output)
-
- def get_command_output(command):
- return get_command_status_output(command)[1]
-
- cmp_ = lambda x, y: (x > y) - (x < y)
-
-def bitcast_to_string(b):
+def bitcast_to_string(b: bytes) -> str:
"""
- Take a string(PY2) or a bytes(PY3) object and return a string. The returned
- string contains the exact same bytes as the input object (latin1 <-> unicode
- transformation is an identity operation for the first 256 code points).
+ Take a bytes object and return a string. The returned string contains the
+ exact same bytes as the input object. (latin1 <-> unicode transformation is
+ an identity operation for the first 256 code points).
"""
- return b if six.PY2 else b.decode("latin1")
+ return b.decode("latin1")
-def bitcast_to_bytes(s):
+def bitcast_to_bytes(s: str) -> bytes:
"""
- Take a string and return a string(PY2) or a bytes(PY3) object. The returned
- object contains the exact same bytes as the input string. (latin1 <->
- unicode transformation is an identity operation for the first 256 code
- points).
+ Take a string and return a bytes object. The returned object contains the
+ exact same bytes as the input string. (latin1 <-> unicode transformation isi
+ an identity operation for the first 256 code points).
"""
- return s if six.PY2 else s.encode("latin1")
+ return s.encode("latin1")
def unhexlify(hexstr):
"""Hex-decode a string. The result is always a string."""
Index: lldb/packages/Python/lldbsuite/support/encoded_file.py
===================================================================
--- lldb/packages/Python/lldbsuite/support/encoded_file.py
+++ lldb/packages/Python/lldbsuite/support/encoded_file.py
@@ -10,26 +10,12 @@
# Python modules:
import io
-# Third party modules
-import six
-
-
-def _encoded_read(old_read, encoding):
- def impl(size):
- result = old_read(size)
- # If this is Python 2 then we need to convert the resulting `unicode` back
- # into a `str` before returning
- if six.PY2:
- result = result.encode(encoding)
- return result
- return impl
-
def _encoded_write(old_write, encoding):
def impl(s):
- # If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it
- # as unicode before attempting to write.
- if isinstance(s, six.binary_type):
+ # If we were asked to write a `bytes` decode it as unicode before
+ # attempting to write.
+ if isinstance(s, bytes):
s = s.decode(encoding, "replace")
# Filter unreadable characters, Python 3 is stricter than python 2 about them.
import re
@@ -38,9 +24,8 @@
return impl
'''
-Create a Text I/O file object that can be written to with either unicode strings or byte strings
-under Python 2 and Python 3, and automatically encodes and decodes as necessary to return the
-native string type for the current Python version
+Create a Text I/O file object that can be written to with either unicode strings
+or byte strings.
'''
@@ -60,8 +45,6 @@
errors=errors,
newline=newline,
closefd=closefd)
- new_read = _encoded_read(getattr(wrapped_file, 'read'), encoding)
new_write = _encoded_write(getattr(wrapped_file, 'write'), encoding)
- setattr(wrapped_file, 'read', new_read)
setattr(wrapped_file, 'write', new_write)
return wrapped_file
Index: lldb/examples/summaries/synth.py
===================================================================
--- lldb/examples/summaries/synth.py
+++ lldb/examples/summaries/synth.py
@@ -33,8 +33,7 @@
def gen_child(self, name, value):
data = None
type = None
- import six
- if isinstance(value, six.integer_types):
+ if isinstance(value, int):
data = lldb.SBData.CreateDataFromUInt64Array(
self.bo, self.ps, [value])
type = self.value.target.GetBasicType(lldb.eBasicTypeLong)
Index: lldb/examples/python/scripted_process/scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/scripted_process.py
+++ lldb/examples/python/scripted_process/scripted_process.py
@@ -1,10 +1,8 @@
from abc import ABCMeta, abstractmethod
-import six
import lldb
[email protected]_metaclass(ABCMeta)
-class ScriptedProcess:
+class ScriptedProcess(metaclass=ABCMeta):
"""
The base class for a scripted process.
@@ -193,8 +191,7 @@
"""
return None
[email protected]_metaclass(ABCMeta)
-class ScriptedThread:
+class ScriptedThread(metaclass=ABCMeta):
"""
The base class for a scripted thread.
Index: lldb/bindings/python/python.swig
===================================================================
--- lldb/bindings/python/python.swig
+++ lldb/bindings/python/python.swig
@@ -84,8 +84,6 @@
import uuid
import re
import os
-
-import six
%}
// Include the version of swig that was used to generate this interface.
Index: lldb/bindings/interface/SBData.i
===================================================================
--- lldb/bindings/interface/SBData.i
+++ lldb/bindings/interface/SBData.i
@@ -157,7 +157,7 @@
for x in range(*key.indices(self.__len__())):
list.append(self.__getitem__(x))
return list
- if not (isinstance(key,six.integer_types)):
+ if not (isinstance(key, int)):
raise TypeError('must be int')
key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here
error = SBError()
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits