Skip to content

Commit b6b159d

Browse files
cclaussslozier
andauthored
eng/scripts: print() is a function in Python 3 (#2011)
* eng/scripts: print() is a function in Python 3 * Remove import print_function --------- Co-authored-by: Stéphane Lozier <slozier@users.noreply.github.com>
1 parent 0e0d654 commit b6b159d

8 files changed

Lines changed: 30 additions & 30 deletions

File tree

eng/scripts/CompareDirs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ def compare_dirs(dir1, dir2):
2121

2222
def main():
2323
if len(sys.argv)!=3:
24-
print 'Usage: CompareDirs <dir1> <dir2>'
24+
print('Usage: CompareDirs <dir1> <dir2>')
2525
sys.exit(-1)
2626

2727
if compare_dirs(sys.argv[1],sys.argv[2]):
28-
print "The directories are identical"
28+
print("The directories are identical")
2929
sys.exit(0)
3030
else: #the part that differed is explained via dircmp.report() above
31-
print "The directories differ"
31+
print("The directories differ")
3232
sys.exit(1)
3333

3434
if __name__=="__main__":

eng/scripts/clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def do_dir(dirname):
1717
if os.path.isdir(filename):
1818
do_dir(filename)
1919
elif is_binary(filename):
20-
print 'deleting', filename
20+
print('deleting', filename)
2121
os.remove(filename)
2222

2323
TOP_DIR = "c:\\IronPython-0.7"

eng/scripts/copyrights.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@
5151
def add_header(filename, old_header, new_header):
5252
text = open(filename, 'r').read()
5353
if text.startswith(old_header):
54-
print "replacing header", filename
54+
print("replacing header", filename)
5555
text = new_header + text[len(old_header):]
5656
open(filename, 'w').write(text)
5757
elif not text.startswith(new_header):
58-
print 'no old header', filename
58+
print('no old header', filename)
5959
text = new_header + "\n" + text
6060
open(filename, 'w').write(text)
6161

6262
def do_dir(dirname):
6363
import os
6464
for file in os.listdir(dirname):
65-
print "Processing:", file
65+
print("Processing:", file)
6666
if file == "ExternalCode": continue
6767
filename = os.path.join(dirname, file)
6868
if os.path.isdir(filename):

eng/scripts/make_meta1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(self, name, super_name, methods):
151151
self.strings = {}
152152

153153
def get_constant_string(self, s):
154-
if not self.strings.has_key(s):
154+
if s not in self.strings:
155155
self.strings[s] = s + "_str"
156156

157157
return self.strings[s]
@@ -235,7 +235,7 @@ def collect_methods(text):
235235
#if c.super_name != 'PyModule':
236236
# assert c.super_name == base.name, c.super_name
237237

238-
print c, c.methods
238+
print(c, c.methods)
239239
code = c.make_any_methods()
240240
code.insert(0, START)
241241
code.append(END)

eng/scripts/radix_generator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
# See the LICENSE file in the project root for more information.
44

5-
max_uint = 0xffffffffl
6-
print max_uint
5+
max_uint = 0xffffffff
6+
print(max_uint)
77

88
digits = ['0','0']
99
radii = ['0','0']
1010
for i in range(2, 37):
1111
p = 1
1212
while i**(p+1) <= max_uint:
1313
p = p+1
14-
print i, p, i**p
14+
print(i, p, i**p)
1515
digits.append(str(p))
1616
radii.append(str(i**p))
17-
print digits, radii
17+
print(digits, radii)
1818

19-
print ", ".join(digits)
20-
print ", ".join(radii)
19+
print(", ".join(digits))
20+
print(", ".join(radii))
2121

eng/scripts/run_compiled.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
def main():
1010
if len(sys.argv) != 2:
11-
print "Usage: ipy run_compiled.py <testfile.py>"
11+
print("Usage: ipy run_compiled.py <testfile.py>")
1212
sys.exit(-1)
1313

1414
testName = sys.argv[1]
1515

16-
print "Compiling ", testName ,"..."
16+
print("Compiling ", testName ,"...")
1717
clr.CompileModules("compiledTest.dll", testName)
1818
File.Move(testName, testName+".bak")
1919
try:
20-
print "Running test from compiled binary..."
20+
print("Running test from compiled binary...")
2121
clr.AddReference("compiledTest")
2222
__import__(Path.GetFileNameWithoutExtension(testName))
2323
finally:

eng/scripts/run_interactive.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,24 @@ def run_interactive_main():
111111
if testName:
112112
testsToRun = Directory.GetFiles(Directory.GetCurrentDirectory() , testName)
113113
else:
114-
print "No test name provided"
114+
print("No test name provided")
115115
sys.exit(-1)
116116

117117
allErrors = []
118118
for test in testsToRun:
119119
try:
120-
print "\nRunning test in interactive mode - ", test
120+
print("\nRunning test in interactive mode - ", test)
121121
con = FileConsole(test)
122122
con.Run()
123-
except Exception, e:
124-
print e, e.clsException
123+
except Exception as e:
124+
print(e, e.clsException)
125125
allErrors.append((test, sys.exc_info()[0], sys.exc_info()[1]))
126126

127127
if(allErrors):
128-
print "\n##################################################################################"
129-
print "Summary of all errors"
128+
print("\n##################################################################################")
129+
print("Summary of all errors")
130130
for file, type, message in allErrors:
131-
print file, type, message
131+
print(file, type, message)
132132
sys.exit(len(allErrors))
133133

134134
#--------------------------------------------------------------------------------------

eng/scripts/test_builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
newline = os.linesep
88

9-
pats = [0L, 1L, 42L, 0x7fffffffL, 0x80000000L, 0xabcdef01L, 0xffffffffL]
9+
pats = [0, 1, 42, 0x7fffffff, 0x80000000, 0xabcdef01, 0xffffffff]
1010
nums = []
1111
for p0 in pats:
1212
for p1 in pats:
@@ -23,7 +23,7 @@
2323
bignums.append(n)
2424
bignums.append(-n)
2525
#!!! should add 2 or 3 larger numbers to check for any issues there
26-
print len(bignums), len(bignums)**2
26+
print(len(bignums), len(bignums)**2)
2727

2828

2929

@@ -40,15 +40,15 @@
4040
]
4141

4242
def buildit(name, nums):
43-
print 'expected', (len(nums)**2)*len(ops)
43+
print('expected', (len(nums)**2)*len(ops))
4444
t0 = time.clock()
4545

4646
for sym, op in ops:
4747
if not name.startswith('time'):
4848
fp = open('%s_%s.txt' % (name, op.__name__), 'w')
4949
else:
5050
fp = None
51-
print 'computing', sym
51+
print('computing', sym)
5252
for x in nums:
5353
for y in nums:
5454
try:
@@ -63,7 +63,7 @@ def buildit(name, nums):
6363
fp.write('ERROR' + newline)
6464
if fp: fp.close()
6565
t1 = time.clock()
66-
print 'time', (t1-t0)
66+
print('time', (t1-t0))
6767

6868
buildit('time1', bignums)
6969
buildit('short', nums)

0 commit comments

Comments
 (0)