[libc++][NFC] Resolve Python 2 FIXME
We don't use Python 2 anymore, so let us do the recommended fix instead
of using the workaround made for Python 2.
Differential Revision: https://reviews.llvm.org/D107715
GitOrigin-RevId: f46f93b4786377dd7ee704ef2beedadfe4f05adf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 657714f..5ab8a30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,17 +46,7 @@
if (LIBCXX_STANDALONE_BUILD)
find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_Interpreter_FOUND)
- message(WARNING "Python3 not found, using python2 as a fallback")
- find_package(Python2 COMPONENTS Interpreter REQUIRED)
- if(Python2_VERSION VERSION_LESS 2.7)
- message(SEND_ERROR "Python 2.7 or newer is required")
- endif()
-
- # Treat python2 as python3
- add_executable(Python3::Interpreter IMPORTED)
- set_target_properties(Python3::Interpreter PROPERTIES
- IMPORTED_LOCATION ${Python2_EXECUTABLE})
- set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
+ message(SEND_ERROR "Python3 not found. Python3 is required")
endif()
endif()
diff --git a/utils/gdb/libcxx/printers.py b/utils/gdb/libcxx/printers.py
index 9805ae9..1b728a4 100644
--- a/utils/gdb/libcxx/printers.py
+++ b/utils/gdb/libcxx/printers.py
@@ -147,10 +147,6 @@
self.count += 1
return ("[%d]" % self.count, child)
- # TODO Delete when we drop Python 2.
- def next(self):
- return self.__next__()
-
def __init__(self, val):
self.val = val
@@ -370,10 +366,6 @@
self.offset = 0
return ("[%d]" % self.count, outbit)
- # TODO Delete when we drop Python 2.
- def next(self):
- return self.__next__()
-
class _VectorIterator(object):
"""Class to iterate over the non-bool vector's children."""
@@ -393,10 +385,6 @@
self.item += 1
return ("[%d]" % self.count, entry)
- # TODO Delete when we drop Python 2.
- def next(self):
- return self.__next__()
-
def __init__(self, val):
"""Set val, length, capacity, and iterator for bool and normal vectors."""
self.val = val
diff --git a/utils/libcxx/util.py b/utils/libcxx/util.py
index 8c93f39..d9440f6 100644
--- a/utils/libcxx/util.py
+++ b/utils/libcxx/util.py
@@ -102,7 +102,7 @@
(or the PATH environment variable, if unspecified)."""
if paths is None:
- paths = os.environ.get('PATH','')
+ paths = os.environ.get('PATH', '')
# Check for absolute match first.
if os.path.isfile(command):
@@ -202,23 +202,20 @@
stderr=subprocess.PIPE,
env=env, close_fds=kUseCloseFDs)
timerObject = None
- # FIXME: Because of the way nested function scopes work in Python 2.x we
- # need to use a reference to a mutable object rather than a plain
- # bool. In Python 3 we could use the "nonlocal" keyword but we need
- # to support Python 2 as well.
- hitTimeOut = [False]
+ hitTimeOut = False
try:
if timeout > 0:
def killProcess():
# We may be invoking a shell so we need to kill the
# process and all its children.
- hitTimeOut[0] = True
+ nonlocal hitTimeOut
+ hitTimeOut = True
killProcessAndChildren(p.pid)
timerObject = threading.Timer(timeout, killProcess)
timerObject.start()
- out,err = p.communicate(input=input)
+ out, err = p.communicate(input=input)
exitCode = p.wait()
finally:
if timerObject != None:
@@ -228,7 +225,7 @@
out = convert_string(out)
err = convert_string(err)
- if hitTimeOut[0]:
+ if hitTimeOut:
raise ExecuteCommandTimeoutException(
msg='Reached timeout of {} seconds'.format(timeout),
out=out,
diff --git a/utils/ssh.py b/utils/ssh.py
index d6346fc..6c1d706 100755
--- a/utils/ssh.py
+++ b/utils/ssh.py
@@ -23,11 +23,7 @@
import tarfile
import tempfile
-try:
- from shlex import quote as cmd_quote
-except ImportError:
- # for Python 2 compatibility
- from pipes import quote as cmd_quote
+from shlex import quote as cmd_quote
def ssh(args, command):
cmd = ['ssh', '-oBatchMode=yes']