From 772660aee5279f2cdc92b807d57f6fa523ea2380 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 11 Mar 2026 23:36:34 +0100 Subject: [PATCH 1/2] eng/scripts: print() is a function in Python 3 --- eng/scripts/CompareDirs.py | 7 ++++--- eng/scripts/clean.py | 3 ++- eng/scripts/copyrights.py | 7 ++++--- eng/scripts/make_meta1.py | 5 +++-- eng/scripts/radix_generator.py | 13 +++++++------ eng/scripts/run_compiled.py | 7 ++++--- eng/scripts/run_interactive.py | 15 ++++++++------- eng/scripts/test_builder.py | 11 ++++++----- 8 files changed, 38 insertions(+), 30 deletions(-) diff --git a/eng/scripts/CompareDirs.py b/eng/scripts/CompareDirs.py index 910a10ae9..83e75251d 100644 --- a/eng/scripts/CompareDirs.py +++ b/eng/scripts/CompareDirs.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -21,14 +22,14 @@ def compare_dirs(dir1, dir2): def main(): if len(sys.argv)!=3: - print 'Usage: CompareDirs ' + print('Usage: CompareDirs ') sys.exit(-1) if compare_dirs(sys.argv[1],sys.argv[2]): - print "The directories are identical" + print("The directories are identical") sys.exit(0) else: #the part that differed is explained via dircmp.report() above - print "The directories differ" + print("The directories differ") sys.exit(1) if __name__=="__main__": diff --git a/eng/scripts/clean.py b/eng/scripts/clean.py index a1dcca92c..8146317e3 100644 --- a/eng/scripts/clean.py +++ b/eng/scripts/clean.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -17,7 +18,7 @@ def do_dir(dirname): if os.path.isdir(filename): do_dir(filename) elif is_binary(filename): - print 'deleting', filename + print('deleting', filename) os.remove(filename) TOP_DIR = "c:\\IronPython-0.7" diff --git a/eng/scripts/copyrights.py b/eng/scripts/copyrights.py index 3df0e8d39..16ecad5c3 100644 --- a/eng/scripts/copyrights.py +++ b/eng/scripts/copyrights.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -51,18 +52,18 @@ def add_header(filename, old_header, new_header): text = open(filename, 'r').read() if text.startswith(old_header): - print "replacing header", filename + print("replacing header", filename) text = new_header + text[len(old_header):] open(filename, 'w').write(text) elif not text.startswith(new_header): - print 'no old header', filename + print('no old header', filename) text = new_header + "\n" + text open(filename, 'w').write(text) def do_dir(dirname): import os for file in os.listdir(dirname): - print "Processing:", file + print("Processing:", file) if file == "ExternalCode": continue filename = os.path.join(dirname, file) if os.path.isdir(filename): diff --git a/eng/scripts/make_meta1.py b/eng/scripts/make_meta1.py index 8554a80ee..dcbff1dba 100644 --- a/eng/scripts/make_meta1.py +++ b/eng/scripts/make_meta1.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -151,7 +152,7 @@ def __init__(self, name, super_name, methods): self.strings = {} def get_constant_string(self, s): - if not self.strings.has_key(s): + if s not in self.strings: self.strings[s] = s + "_str" return self.strings[s] @@ -235,7 +236,7 @@ def collect_methods(text): #if c.super_name != 'PyModule': # assert c.super_name == base.name, c.super_name - print c, c.methods + print(c, c.methods) code = c.make_any_methods() code.insert(0, START) code.append(END) diff --git a/eng/scripts/radix_generator.py b/eng/scripts/radix_generator.py index 5f4ea03eb..d847ab689 100644 --- a/eng/scripts/radix_generator.py +++ b/eng/scripts/radix_generator.py @@ -1,9 +1,10 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. -max_uint = 0xffffffffl -print max_uint +max_uint = 0xffffffff +print(max_uint) digits = ['0','0'] radii = ['0','0'] @@ -11,11 +12,11 @@ p = 1 while i**(p+1) <= max_uint: p = p+1 - print i, p, i**p + print(i, p, i**p) digits.append(str(p)) radii.append(str(i**p)) -print digits, radii +print(digits, radii) -print ", ".join(digits) -print ", ".join(radii) +print(", ".join(digits)) +print(", ".join(radii)) diff --git a/eng/scripts/run_compiled.py b/eng/scripts/run_compiled.py index 782420d10..5135987da 100644 --- a/eng/scripts/run_compiled.py +++ b/eng/scripts/run_compiled.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -8,16 +9,16 @@ def main(): if len(sys.argv) != 2: - print "Usage: ipy run_compiled.py " + print("Usage: ipy run_compiled.py ") sys.exit(-1) testName = sys.argv[1] - print "Compiling ", testName ,"..." + print("Compiling ", testName ,"...") clr.CompileModules("compiledTest.dll", testName) File.Move(testName, testName+".bak") try: - print "Running test from compiled binary..." + print("Running test from compiled binary...") clr.AddReference("compiledTest") __import__(Path.GetFileNameWithoutExtension(testName)) finally: diff --git a/eng/scripts/run_interactive.py b/eng/scripts/run_interactive.py index 1d6140577..2ac2c4728 100644 --- a/eng/scripts/run_interactive.py +++ b/eng/scripts/run_interactive.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -111,24 +112,24 @@ def run_interactive_main(): if testName: testsToRun = Directory.GetFiles(Directory.GetCurrentDirectory() , testName) else: - print "No test name provided" + print("No test name provided") sys.exit(-1) allErrors = [] for test in testsToRun: try: - print "\nRunning test in interactive mode - ", test + print("\nRunning test in interactive mode - ", test) con = FileConsole(test) con.Run() - except Exception, e: - print e, e.clsException + except Exception as e: + print(e, e.clsException) allErrors.append((test, sys.exc_info()[0], sys.exc_info()[1])) if(allErrors): - print "\n##################################################################################" - print "Summary of all errors" + print("\n##################################################################################") + print("Summary of all errors") for file, type, message in allErrors: - print file, type, message + print(file, type, message) sys.exit(len(allErrors)) #-------------------------------------------------------------------------------------- diff --git a/eng/scripts/test_builder.py b/eng/scripts/test_builder.py index 2414ec955..73b7c1c56 100644 --- a/eng/scripts/test_builder.py +++ b/eng/scripts/test_builder.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. @@ -6,7 +7,7 @@ import os newline = os.linesep -pats = [0L, 1L, 42L, 0x7fffffffL, 0x80000000L, 0xabcdef01L, 0xffffffffL] +pats = [0, 1, 42, 0x7fffffff, 0x80000000, 0xabcdef01, 0xffffffff] nums = [] for p0 in pats: for p1 in pats: @@ -23,7 +24,7 @@ bignums.append(n) bignums.append(-n) #!!! should add 2 or 3 larger numbers to check for any issues there -print len(bignums), len(bignums)**2 +print(len(bignums), len(bignums)**2) @@ -40,7 +41,7 @@ ] def buildit(name, nums): - print 'expected', (len(nums)**2)*len(ops) + print('expected', (len(nums)**2)*len(ops)) t0 = time.clock() for sym, op in ops: @@ -48,7 +49,7 @@ def buildit(name, nums): fp = open('%s_%s.txt' % (name, op.__name__), 'w') else: fp = None - print 'computing', sym + print('computing', sym) for x in nums: for y in nums: try: @@ -63,7 +64,7 @@ def buildit(name, nums): fp.write('ERROR' + newline) if fp: fp.close() t1 = time.clock() - print 'time', (t1-t0) + print('time', (t1-t0)) buildit('time1', bignums) buildit('short', nums) From cf9ba9e14e3b8bb779efb6a92022262207844516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lozier?= Date: Wed, 11 Mar 2026 21:09:59 -0400 Subject: [PATCH 2/2] Remove import print_function --- eng/scripts/CompareDirs.py | 1 - eng/scripts/clean.py | 1 - eng/scripts/copyrights.py | 1 - eng/scripts/make_meta1.py | 1 - eng/scripts/radix_generator.py | 1 - eng/scripts/run_compiled.py | 1 - eng/scripts/run_interactive.py | 1 - eng/scripts/test_builder.py | 1 - 8 files changed, 8 deletions(-) diff --git a/eng/scripts/CompareDirs.py b/eng/scripts/CompareDirs.py index 83e75251d..b63651df4 100644 --- a/eng/scripts/CompareDirs.py +++ b/eng/scripts/CompareDirs.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/clean.py b/eng/scripts/clean.py index 8146317e3..6dbfc95eb 100644 --- a/eng/scripts/clean.py +++ b/eng/scripts/clean.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/copyrights.py b/eng/scripts/copyrights.py index 16ecad5c3..243b72a91 100644 --- a/eng/scripts/copyrights.py +++ b/eng/scripts/copyrights.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/make_meta1.py b/eng/scripts/make_meta1.py index dcbff1dba..24d7e359d 100644 --- a/eng/scripts/make_meta1.py +++ b/eng/scripts/make_meta1.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/radix_generator.py b/eng/scripts/radix_generator.py index d847ab689..bfa8da83b 100644 --- a/eng/scripts/radix_generator.py +++ b/eng/scripts/radix_generator.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/run_compiled.py b/eng/scripts/run_compiled.py index 5135987da..8207ef7e4 100644 --- a/eng/scripts/run_compiled.py +++ b/eng/scripts/run_compiled.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/run_interactive.py b/eng/scripts/run_interactive.py index 2ac2c4728..182351176 100644 --- a/eng/scripts/run_interactive.py +++ b/eng/scripts/run_interactive.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information. diff --git a/eng/scripts/test_builder.py b/eng/scripts/test_builder.py index 73b7c1c56..aec44ea1a 100644 --- a/eng/scripts/test_builder.py +++ b/eng/scripts/test_builder.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information.