Portable Python script across Python version
Using from __future__ import print_function it is possible to have a compatible behavior of `print(...)` across Python version.
Differential Revision: https://reviews.llvm.org/D55213
llvm-svn: 349454
diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index ef0ab19..70c425d 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -122,7 +122,7 @@
else:
Clang = SATestUtils.which("clang", os.environ['PATH'])
if not Clang:
- print "Error: cannot find 'clang' in PATH"
+ print("Error: cannot find 'clang' in PATH")
sys.exit(1)
# Number of jobs.
@@ -570,8 +570,8 @@
NewList.remove(os.path.join(NewDir, LogFolderName))
if len(RefList) != len(NewList):
- print "Mismatch in number of results folders: %s vs %s" % (
- RefList, NewList)
+ print("Mismatch in number of results folders: %s vs %s" % (
+ RefList, NewList))
sys.exit(1)
# There might be more then one folder underneath - one per each scan-build
@@ -719,11 +719,11 @@
"""
for I in iterateOverProjects(PMapFile):
if len(I) != 2:
- print "Error: Rows in the ProjectMapFile should have 2 entries."
+ print("Error: Rows in the ProjectMapFile should have 2 entries.")
raise Exception()
if I[1] not in ('0', '1', '2'):
- print "Error: Second entry in the ProjectMapFile should be 0" \
- " (single file), 1 (project), or 2(single file c++11)."
+ print("Error: Second entry in the ProjectMapFile should be 0" \
+ " (single file), 1 (project), or 2(single file c++11).")
raise Exception()
def singleThreadedTestAll(Args, ProjectsToTest):
@@ -806,5 +806,5 @@
TestsPassed = testAll(Args)
if not TestsPassed:
- print "ERROR: Tests failed."
+ print("ERROR: Tests failed.")
sys.exit(42)