Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):

# Replace uses of /dev/null with temporary files.
if kAvoidDevNull:
# In Python 2.x, basestring is the base class for all string (including unicode)
# In Python 3.x, basestring no longer exist and str is always unicode
try:
str_type = basestring
except NameError:
str_type = str
for i, arg in enumerate(args):
if isinstance(arg, str_type) and kDevNull in arg:
if isinstance(arg, str) and kDevNull in arg:
f = tempfile.NamedTemporaryFile(delete=False)
f.close()
named_temp_files.append(f.name)
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/lit/lit/llvm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def with_environment(self, variable, value, append_path=False):
# For paths, we should be able to take a list of them and process
# all of them.
paths_to_add = value
if lit.util.is_string(paths_to_add):
if isinstance(paths_to_add, str):
paths_to_add = [paths_to_add]

def norm(x):
Expand Down Expand Up @@ -259,7 +259,7 @@ def norm(x):
self.config.environment[variable] = value

def with_system_environment(self, variables, append_path=False):
if lit.util.is_string(variables):
if isinstance(variables, str):
variables = [variables]
for v in variables:
value = os.environ.get(v)
Expand Down Expand Up @@ -401,7 +401,7 @@ def add_tool_substitutions(self, tools, search_dirs=None):
if not search_dirs:
search_dirs = [self.config.llvm_tools_dir]

if lit.util.is_string(search_dirs):
if isinstance(search_dirs, str):
search_dirs = [search_dirs]

tools = [x if isinstance(x, ToolSubst) else ToolSubst(x) for x in tools]
Expand Down
10 changes: 1 addition & 9 deletions llvm/utils/lit/lit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,14 @@
import threading


def is_string(value):
try:
# Python 2 and Python 3 are different here.
return isinstance(value, basestring)
except NameError:
return isinstance(value, str)


def pythonize_bool(value):
if value is None:
return False
if type(value) is bool:
return value
if isinstance(value, numbers.Number):
return value != 0
if is_string(value):
if isinstance(value, str):
if value.lower() in ("1", "true", "on", "yes"):
return True
if value.lower() in ("", "0", "false", "off", "no"):
Expand Down