Skip to content

Commit e455056

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: print using print function
Use print function from future's print_function instead of a print statement since the latter does not exist in Python 3. This was produced by running futurize's stage1 libfuturize.fixes.fix_print_with_import. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls Reviewed By: hubert.reinterpretcast Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67813 llvm-svn: 372553
1 parent a7aaae6 commit e455056

File tree

10 files changed

+68
-58
lines changed

10 files changed

+68
-58
lines changed

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14+
from __future__ import print_function
1415
import datetime
1516
import sys
1617
import os
@@ -20,7 +21,7 @@
2021
try:
2122
import sphinx_bootstrap_theme
2223
except ImportError:
23-
print "Warning: Sphinx Bootstrap Theme package is not installed!"
24+
print("Warning: Sphinx Bootstrap Theme package is not installed!")
2425
use_bootstrap = False
2526

2627
# If extensions (or modules to document with autodoc) are in another directory,

examples/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Simple example of a test generator which just produces data on some
44
mathematical functions, keyed off of the current time.
55
"""
6+
from __future__ import print_function
67
from lnt.testing import Machine, Run, TestSamples, Report
78
import math
89
import random
@@ -47,7 +48,7 @@ def main():
4748

4849
report = Report(machine, run, tests)
4950

50-
print >>output, report.render()
51+
print(report.render(), file=output)
5152

5253
if output is not sys.stderr:
5354
output.close()

examples/run_to_csv.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Convert the JSON run file passed on stdin to a csv"""
2+
from __future__ import print_function
23
import json
34

45
import sys
@@ -9,11 +10,11 @@
910
titles = data['tests'].itervalues().next().keys()
1011
titles.insert(0, titles.pop(titles.index("name")))
1112

12-
print ", ".join(titles)
13+
print(", ".join(titles))
1314

1415
for i, result in data['tests'].items():
1516

1617
for title in titles:
17-
print result[title],
18-
print ", ",
19-
print
18+
print(result[title], end=' ')
19+
print(", ", end=' ')
20+
print()

tests/SharedInputs/FakeCompilers/fakecompiler.py

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
Utilities for "faking" a compiler response.
55
"""
6+
from __future__ import print_function
67

78
import inspect
89
import os
@@ -24,34 +25,34 @@ def print_llvm_target(self, args):
2425
raise NotImplementedError
2526

2627
def print_as_version(self):
27-
print >> sys.stderr, """(assembler version goes here)"""
28+
print("""(assembler version goes here)""", file=sys.stderr)
2829

2930
def print_ld_version(self):
30-
print >> sys.stderr, """(linker version goes here)"""
31+
print("""(linker version goes here)""", file=sys.stderr)
3132

3233

3334
class ICCv12_1_3(FakeCompiler):
3435
compiler_name = "icc-12.1.3"
3536

3637
def print_verbose_info(self):
37-
print >> sys.stderr, """\
38+
print("""\
3839
icc: command line warning #10006: ignoring unknown option '-###'
3940
icc version 12.1.3 (gcc version 4.2.1 compatibility)
4041
/usr/bin/icc-2011-base/bin/intel64/mcpcom -_g -mP3OPT_inline_alloca -D__HONOR_STD -D__ICC=1210 -D__INTEL_COMPILER=1210 "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__BLOCKS__ -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int -D__WINT_TYPE__=int "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__NO_INLINE__ -D__GNUC_GNU_INLINE__ -D__GNUC__=4 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__APPLE_CC__=5658 -D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1073 -D__LITTLE_ENDIAN__ -D__DYNAMIC__ "-D__private_extern__=__attribute__((visibility("hidden")))" -D__LP64__ -D_LP64 -D__GXX_ABI_VERSION=1002 -D__USER_LABEL_PREFIX__=_ -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__x86_64 -D__x86_64__ -D_MT -D__INTEL_COMPILER_BUILD_DATE=20120130 -D__PIC__ -D__APPLE__ -D__MACH__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE__ -D__MMX__ -_k -_8 -_l -_D -_a -_b -E --gnu_version=421 -_W5 --gcc-extern-inline --multibyte_chars --blocks --array_section --simd --simd_func -mP1OPT_print_version=FALSE -mP1OPT_version=12.1-intel64 -mGLOB_diag_use_message_catalog=FALSE /dev/null
4142
... more boring stuff here ...
42-
""" # noqa
43+
""", file=sys.stderr) # noqa
4344

4445
def print_llvm_target(self, args):
45-
print """\
46+
print("""\
4647
icc: command line warning #10006: ignoring unknown option '-flto'
4748
.file "null"
4849
.section __DATA, __data
4950
# End
5051
.subsections_via_symbols
51-
""" # noqa
52+
""") # noqa
5253

5354
def print_dumpmachine(self):
54-
print """i686-apple-darwin11"""
55+
print("""i686-apple-darwin11""")
5556

5657

5758
class LLVMCompiler(FakeCompiler):
@@ -60,95 +61,95 @@ def print_llvm_target(self, args):
6061
for arg in args:
6162
if arg.startswith("--target="):
6263
target = arg[len("--target="):]
63-
print """\
64+
print("""\
6465
; ModuleID = '/dev/null'
6566
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
6667
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-\
6768
n8:16:32:64"
6869
target triple = "%s"
69-
""" % target
70+
""" % target)
7071

7172
def print_dumpmachine(self):
72-
print """x86_64-apple-darwin11.0.0"""
73+
print("""x86_64-apple-darwin11.0.0""")
7374

7475

7576
# Clang build at r154331 (for example).
7677
class Clang_r154331(LLVMCompiler):
7778
compiler_name = "clang-r154331"
7879

7980
def print_verbose_info(self):
80-
print >> sys.stderr, """\
81+
print("""\
8182
clang version 3.1 (trunk 154331) (llvm/trunk 154329)
8283
Target: x86_64-apple-darwin11.3.0
8384
Thread model: posix
8485
InstalledDir: /home/foo/bin
85-
"""
86-
print >> sys.stderr, """\
86+
""", file=sys.stderr)
87+
print("""\
8788
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
88-
g_program,)
89+
g_program,), file=sys.stderr)
8990

9091

9192
class Clang_r154332(LLVMCompiler):
9293
compiler_name = "clang-r154332"
9394

9495
def print_verbose_info(self):
95-
print >> sys.stderr, """\
96+
print("""\
9697
clang version 3.1 (trunk 154332) (llvm/trunk 154329)
9798
Target: x86_64-apple-darwin11.3.0
9899
Thread model: posix
99100
InstalledDir: /home/foo/bin
100-
"""
101-
print >> sys.stderr, """\
101+
""", file=sys.stderr)
102+
print("""\
102103
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
103-
g_program,)
104+
g_program,), file=sys.stderr)
104105

105106

106107
# Clang build from a git repository.
107108
class Clang_git(LLVMCompiler):
108109
compiler_name = "clang-git"
109110

110111
def print_verbose_info(self):
111-
print >> sys.stderr, """\
112+
print("""\
112113
clang version 3.1\
113114
(git:/git/clang.git 37ce0feee598d82e7220fa0a4b110619cae6ea72)\
114115
(git:/git/llvm.git 60fca4f64e697ad834ce7ee8c2e478cae394c7dc)
115116
Target: arm-apple-darwin11.4.0
116117
Thread model: posix
117118
InstalledDir: /home/foo/bin
118-
"""
119-
print >> sys.stderr, """\
119+
""", file=sys.stderr)
120+
print("""\
120121
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
121-
g_program,)
122+
g_program,), file=sys.stderr)
122123

123124

124125
# Clang build from a git repository.
125126
class Clang_git_2(LLVMCompiler):
126127
compiler_name = "clang-git-2"
127128

128129
def print_verbose_info(self):
129-
print >> sys.stderr, """\
130+
print("""\
130131
clang version 3.2\
131132
(/d/g/pz/clang.git git:/git/pz/clang.git 8ab09316f63ea99ff23b2684c454b1008b8d5f10)\
132133
(http://llvm.org/git/llvm.git /d/g/pz/llvm.git git:/git/pb/llvm.git 7c53f795961cc2d35b85d315aadb2ac135a0fdb2)
133134
Target: x86_64-apple-darwin12.2.0
134-
Thread model: posix"""
135-
print >> sys.stderr, """\
135+
Thread model: posix""", file=sys.stderr)
136+
print("""\
136137
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
137-
g_program,)
138+
g_program,), file=sys.stderr)
138139

139140

140141
class AppleClang_138_1(LLVMCompiler):
141142
compiler_name = "apple-clang-138.1"
142143

143144
def print_verbose_info(self):
144-
print >> sys.stderr, """\
145+
print("""\
145146
Apple clang version 2.0 (tags/Apple/clang-138.1) (based on LLVM 2.9svn)
146147
Target: x86_64-apple-darwin11.3.0
147148
Thread model: posix
148-
InstalledDir: /home/foo/bin"""
149-
print >> sys.stderr, """\
149+
InstalledDir: /home/foo/bin""", file=sys.stderr)
150+
print("""\
150151
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
151-
g_program,)
152+
g_program,), file=sys.stderr)
152153

153154

154155
fake_compilers = dict((value.compiler_name, value)
@@ -160,26 +161,26 @@ class ClangNoInfo(LLVMCompiler):
160161
compiler_name = "clang-no-info"
161162

162163
def print_verbose_info(self):
163-
print >> sys.stderr, """\
164+
print("""\
164165
clang version 3.2
165166
Target: x86_64-bla-bla
166-
Thread model: posix"""
167-
print >> sys.stderr, """\
167+
Thread model: posix""", file=sys.stderr)
168+
print("""\
168169
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
169-
g_program,)
170+
g_program,), file=sys.stderr)
170171

171172

172173
class GenericLLVMCompiler(LLVMCompiler):
173174
compiler_name = "llvm-compiler"
174175

175176
def print_verbose_info(self):
176-
print >> sys.stderr, """\
177+
print("""\
177178
LLVM version 3.3 (git:/git/pz/clang.git 597522d740374f093a089a2acbec5b20466b2f34) (/d/g/pz/llvm git:/git/pz/llvm.git 6e95d969734af111bb33bcec0bcc27fd803a3b76)
178179
Target: x86_64-apple-darwin12.3.0
179-
Thread model: posix""" # noqa
180-
print >> sys.stderr, """\
180+
Thread model: posix""", file=sys.stderr) # noqa
181+
print("""\
181182
"%s" "-cc1" "-E" ... more boring stuff here ...""" % (
182-
g_program,)
183+
g_program,), file=sys.stderr)
183184

184185

185186
fake_compilers = dict((value.compiler_name, value)

tests/SharedInputs/create_temp_instance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23
import shutil
34
import os.path
@@ -69,7 +70,7 @@ def run_sql_file(db, sql_file, dest_dir):
6970
cmd = "psql %s -f %s" % (db, tmpfile_name)
7071
else:
7172
cmd = "sqlite3 -batch %s < %s" % (db, sql_file)
72-
print cmd
73+
print(cmd)
7374
subprocess.check_call(cmd, shell="True")
7475

7576

@@ -78,7 +79,7 @@ def run_sql_cmd(db, sql_cmd):
7879
cmd = 'echo "%s" | psql %s' % (sql_cmd, db)
7980
else:
8081
cmd = 'echo "%s" | sqlite3 -batch %s' % (sql_cmd, db)
81-
print cmd
82+
print(cmd)
8283
subprocess.check_call(cmd, shell="True")
8384

8485

@@ -109,7 +110,7 @@ def create_tmp_database(db, test_name, dest_dir):
109110
def main():
110111
usage = "%s test_name template_source_dir dest_dir [extra.sql]"
111112
if len(sys.argv) not in (4, 5):
112-
print usage
113+
print(usage)
113114
sys.exit(-1)
114115
if len(sys.argv) == 4:
115116
_, test_name, template_source_dir, dest_dir = sys.argv

tests/server/db/ImportV4TestSuiteInstance.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Check the import process into a v4 test suite DB.
23
#
34
# We first construct a temporary LNT instance.
@@ -107,8 +108,8 @@
107108
orders = list(session.query(ts.Order).order_by(ts.Order.llvm_project_revision))
108109
assert len(orders) == 2
109110
order_a,order_b = orders
110-
print order_a
111-
print order_b
111+
print(order_a)
112+
print(order_b)
112113
assert order_a.previous_order_id is None
113114
assert order_a.next_order_id is order_b.id
114115
assert order_a.llvm_project_revision == '1'
@@ -143,9 +144,9 @@
143144
assert sample_a_0.test is test
144145
assert sample_a_1.test is test
145146
assert sample_b.test is test
146-
print sample_a_0
147-
print sample_a_1
148-
print sample_b
147+
print(sample_a_0)
148+
print(sample_a_1)
149+
print(sample_b)
149150
assert sample_a_0.compile_time == 0.019
150151
assert sample_a_0.compile_status == lnt.testing.PASS
151152
assert sample_a_0.execution_time == 0.3

tests/server/db/Migrations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# RUN: python %s %t
44

5+
from __future__ import print_function
56
import logging
67
import os
78
import re
@@ -31,7 +32,7 @@ def sanity_check_instance(instance_path):
3132
test_suite_list_end = index.data.index("</div>", test_suite_list_start)
3233
for ln in index.data[test_suite_list_start:test_suite_list_end].split("\n"):
3334
# Ignore non-matching lines.
34-
print >>sys.stderr,ln
35+
print(ln, file=sys.stderr)
3536
m = test_suite_link_rex.match(ln)
3637
if not m:
3738
continue

tests/server/ui/V4Pages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Perform basic sanity checking of the V4 UI pages.
23
#
34
# create temporary instance
@@ -103,7 +104,7 @@ def check_redirect(client, url, expected_redirect_regex):
103104

104105
def dump_html(html_string):
105106
for linenr, line in enumerate(html_string.split('\n')):
106-
print "%4d:%s" % (linenr + 1, line)
107+
print("%4d:%s" % (linenr + 1, line))
107108

108109

109110
def get_xml_tree(html_string):

tests/testing/CalltreeDataLoading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Check the model bindings for test suite instances.
23
#
34
# RUN: rm -f %t.db
@@ -8,7 +9,7 @@
89
from lnt.testing.util import valgrind
910

1011
data = valgrind.CalltreeData.frompath(sys.argv[1])
11-
print data
12+
print(data)
1213

1314
assert data.command == 'true'
1415
assert tuple(data.events) == ('Ir', 'I1mr', 'ILmr', 'Dr', 'D1mr', 'DLmr',

0 commit comments

Comments
 (0)