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
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()
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
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."""
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
(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):
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:
out = convert_string(out)
err = convert_string(err)
- if hitTimeOut[0]:
+ if hitTimeOut:
raise ExecuteCommandTimeoutException(
msg='Reached timeout of {} seconds'.format(timeout),
out=out,
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']