From 2ba9035552f09f80d0350e131b19b08f977f5159 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 21:28:20 -0800 Subject: Use print() function to fix py2/3 --- QMTest/TestCmdTests.py | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index cd62d9f..b9226fd 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -245,11 +245,12 @@ class cleanup_TestCase(TestCmdTestCase): def test_atexit(self): """Test cleanup() when atexit is used""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import atexit def my_exitfunc(): - print "my_exitfunc()" + print("my_exitfunc()") atexit.register(my_exitfunc) import TestCmd result = TestCmd.TestCmd(workdir = '') @@ -258,10 +259,11 @@ sys.exit(0) def test_exitfunc(self): """Test cleanup() when sys.exitfunc is set""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path def my_exitfunc(): - print "my_exitfunc()" + print("my_exitfunc()") sys.exitfunc = my_exitfunc import TestCmd result = TestCmd.TestCmd(workdir = '') @@ -594,13 +596,14 @@ sys.exit(0) def test_diff_stderr_not_affecting_diff_stdout(self): """Test diff_stderr() not affecting diff_stdout() behavior""" - self.popen_python(r"""import sys + self.popen_python(r"""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd(diff_stderr='diff_re') -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr('a\nb.\nc\n', 'a\nbb\nc\n') -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout('a\nb.\nc\n', 'a\nbb\nc\n') sys.exit(0) """ % self.orig_cwd, @@ -700,13 +703,14 @@ sys.exit(0) def test_diff_stdout_not_affecting_diff_stderr(self): """Test diff_stdout() not affecting diff_stderr() behavior""" - self.popen_python(r"""import sys + self.popen_python(r"""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd(diff_stdout='diff_re') -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout('a\nb.\nc\n', 'a\nbb\nc\n') -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr('a\nb.\nc\n', 'a\nbb\nc\n') sys.exit(0) """ % self.orig_cwd, @@ -2096,18 +2100,19 @@ sys.exit(0) def test_set_diff_function_stdout(self): """Test set_diff_function(): stdout""" - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd() -print "diff:" +print("diff:") test.diff("a\\n", "a\\n") -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout("a\\n", "a\\n") test.set_diff_function(stdout='diff_re') -print "diff:" +print("diff:") test.diff(".\\n", "a\\n") -print "diff_stdout:" +print("diff_stdout:") test.diff_stdout(".\\n", "a\\n") sys.exit(0) """ % self.orig_cwd, @@ -2124,18 +2129,19 @@ diff_stdout: def test_set_diff_function_stderr(self): """Test set_diff_function(): stderr """ - self.popen_python("""import sys + self.popen_python("""from __future__ import print_function +import sys sys.path = ['%s'] + sys.path import TestCmd test = TestCmd.TestCmd() -print "diff:" +print("diff:") test.diff("a\\n", "a\\n") -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr("a\\n", "a\\n") test.set_diff_function(stderr='diff_re') -print "diff:" +print("diff:") test.diff(".\\n", "a\\n") -print "diff_stderr:" +print("diff_stderr:") test.diff_stderr(".\\n", "a\\n") sys.exit(0) """ % self.orig_cwd, @@ -2696,9 +2702,10 @@ class stdin_TestCase(TestCmdTestCase): def test_stdin(self): """Test stdin()""" run_env = TestCmd.TestCmd(workdir = '') - run_env.write('run', """import fileinput + run_env.write('run', """from __future__ import print_function +import fileinput for line in fileinput.input(): - print 'Y'.join(line[:-1].split('X')) + print('Y'.join(line[:-1].split('X'))) """) run_env.write('input', "X on X this X line X\n") os.chdir(run_env.workdir) @@ -3327,14 +3334,16 @@ class variables_TestCase(TestCmdTestCase): 'TestCmd', ] - script = "import TestCmd\n" + \ - '\n'.join([ "print TestCmd.%s\n" % v for v in variables ]) + script = "from __future__ import print_function\n" + \ + "import TestCmd\n" + \ + '\n'.join([ "print(TestCmd.%s\n)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr - script = "from TestCmd import *\n" + \ - '\n'.join([ "print %s" % v for v in variables ]) + script = "from __future__ import print_function\n" + \ + "from TestCmd import *\n" + \ + '\n'.join([ "print(%s)" % v for v in variables ]) run_env.run(program=sys.executable, stdin=script) stderr = run_env.stderr() assert stderr == "", stderr -- cgit v0.12 From b4a807726365f963db3c5b0f0ba8b459c40a64d2 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 21:29:07 -0800 Subject: Use print() function to fix py2/3 --- test/CXX/CXXVERSION.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/CXX/CXXVERSION.py b/test/CXX/CXXVERSION.py index 6017001..abe6ce0 100644 --- a/test/CXX/CXXVERSION.py +++ b/test/CXX/CXXVERSION.py @@ -38,16 +38,17 @@ if sys.platform == 'win32': test.write("versioned.py", -"""import os +"""from __future__ import print_function +import os import sys if '-dumpversion' in sys.argv: - print '3.9.9' + print('3.9.9') sys.exit(0) if '--version' in sys.argv: - print 'this is version 2.9.9 wrapping', sys.argv[2] + print('this is version 2.9.9 wrapping', sys.argv[2]) sys.exit(0) if sys.argv[1] not in [ '2.9.9', '3.9.9' ]: - print 'wrong version', sys.argv[1], 'when wrapping', sys.argv[2] + print('wrong version', sys.argv[1], 'when wrapping', sys.argv[2]) sys.exit(1) os.system(" ".join(sys.argv[2:])) """) -- cgit v0.12 From f286773d5da1c938954131e93f39d3259e14b640 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:31:02 -0800 Subject: Use print() function to fix py2/3 --- test/explain/save-info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/explain/save-info.py b/test/explain/save-info.py index af4c3f5..545f624 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -42,6 +42,8 @@ inc_ddd = test.workpath('inc', 'ddd') inc_eee = test.workpath('inc', 'eee') test.write(cat_py, r""" +from __future__ import print_function + import sys def process(outfp, infp): @@ -52,7 +54,7 @@ def process(outfp, infp): fp = open(file, 'rb') except IOError: import os - print "os.getcwd() =", os.getcwd() + print("os.getcwd() =", os.getcwd()) raise process(outfp, fp) else: -- cgit v0.12 From 914e670bb555a3a412253eff57eda9ce6e3e4a3a Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:31:30 -0800 Subject: Use print() function to fix py2/3 --- test/explain/basic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/explain/basic.py b/test/explain/basic.py index 1072ac4..7079e44 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -53,6 +53,8 @@ inc_bbb_k = test.workpath('inc', 'bbb.k') test.write(cat_py, r"""#!/usr/bin/env python +from __future__ import print_function + import sys def process(outfp, infp): @@ -63,7 +65,7 @@ def process(outfp, infp): fp = open(file, 'rb') except IOError: import os - print "os.getcwd() =", os.getcwd() + print("os.getcwd() =", os.getcwd()) raise process(outfp, fp) else: -- cgit v0.12 From 85e7b4542ee2cf378db46a09e7d0b7a1aca802b7 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:33:59 -0800 Subject: Use print() function to fix py2/3 --- test/SWIG/build-dir.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index 304932f..eba3fea 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -145,11 +145,13 @@ public: test.write(['source', 'test.py'], """\ #!/usr/bin/env python +from __future__ import print_function + import linalg x = linalg.Vector(5) -print x +print(x) x[1] = 99.5 x[3] = 8.3 @@ -157,7 +159,7 @@ x[4] = 11.1 for i, v in enumerate(x): - print "\tx[%d] = %g" % (i, v) + print("\tx[%d] = %g" % (i, v)) """) -- cgit v0.12 From e179b10881ed0e61226a500ef45e35b76dbe2b4b Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:34:46 -0800 Subject: Use print() function to fix py2/3 --- test/SCONS_LIB_DIR.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/SCONS_LIB_DIR.py b/test/SCONS_LIB_DIR.py index 95a377a..65ec3de 100644 --- a/test/SCONS_LIB_DIR.py +++ b/test/SCONS_LIB_DIR.py @@ -31,8 +31,10 @@ test = TestSCons.TestSCons() test.subdir('SCons') test.write(['SCons','Script.py'], """ +from __future__ import print_function + def main (): - print "SCons.Script" + print("SCons.Script") """) test.write(['SCons','__init__.py'], """ -- cgit v0.12 From 390c4c431abef8b0809a3c30ec07dc6900cb32ce Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:36:28 -0800 Subject: Use print() function to fix py2/3 --- test/QT/Tool.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/QT/Tool.py b/test/QT/Tool.py index 63fb113..9e4a277 100644 --- a/test/QT/Tool.py +++ b/test/QT/Tool.py @@ -22,6 +22,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ @@ -98,7 +100,7 @@ def CheckForQt(context): if os.path.isfile(uic_path): potential_qt_dirs.insert(0, env[ 'qt_directory' ]) else: - print "QT not found. Invalid qt_directory value - failed to find uic." + print("QT not found. Invalid qt_directory value - failed to find uic.") return 0 for i in potential_qt_dirs: @@ -106,21 +108,21 @@ def CheckForQt(context): if CheckForQtAt(context, i): # additional checks to validate QT installation if not os.path.isfile(os.path.join(i, 'bin', 'uic')): - print "QT - failed to find uic." + print("QT - failed to find uic.") return 0 if not os.path.isfile(os.path.join(i, 'bin', 'moc')): - print "QT - failed to find moc." + print("QT - failed to find moc.") return 0 if not os.path.exists(os.path.join(i, 'lib')): - print "QT - failed to find QT lib path." + print("QT - failed to find QT lib path.") return 0 if not os.path.exists(os.path.join(i, 'include')): - print "QT - failed to find QT include path." + print("QT - failed to find QT include path.") return 0 return 1 else: if i==env['qt_directory']: - print "QT directory not valid. Failed QT test build." + print("QT directory not valid. Failed QT test build.") return 0 return 0 @@ -140,7 +142,7 @@ config = env.Configure(custom_tests = { }) if not config.CheckForQt(): - print "Failed to find valid QT environment." + print("Failed to find valid QT environment.") Exit(1) env.Tool('qt', ['$TOOL_PATH']) -- cgit v0.12 From ef2b52bbda4aa2ff98b73d13a0ff32782b25e0fd Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:38:50 -0800 Subject: Use print() function to fix py2/3 --- runtest.py | 4 ++-- src/engine/SCons/Platform/posix.py | 2 +- src/engine/SCons/Tool/FortranCommon.py | 6 +++--- src/engine/SCons/cpp.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtest.py b/runtest.py index d0de6d1..ae456a2 100755 --- a/runtest.py +++ b/runtest.py @@ -210,8 +210,8 @@ parser.add_option('--xml', help="Save results to file in SCons XML format.") (options, args) = parser.parse_args() -#print "options:", options -#print "args:", args +#print("options:", options) +#print("args:", args) opts, args = getopt.getopt(args, "b:def:hj:klnP:p:qsv:Xx:t", diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index 190a2a6..8db08db 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -56,7 +56,7 @@ def escape(arg): for c in special: arg = arg.replace(c, slash+c) - # print "ESCAPE RESULT: %s"%arg + # print("ESCAPE RESULT: %s" % arg) return '"' + arg + '"' diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index e450730..ec409c0 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -207,7 +207,7 @@ def add_f90_to_env(env): except KeyError: F90Suffixes = ['.f90'] - #print "Adding %s to f90 suffixes" % F90Suffixes + #print("Adding %s to f90 suffixes" % F90Suffixes) try: F90PPSuffixes = env['F90PPFILESUFFIXES'] except KeyError: @@ -223,7 +223,7 @@ def add_f95_to_env(env): except KeyError: F95Suffixes = ['.f95'] - #print "Adding %s to f95 suffixes" % F95Suffixes + #print("Adding %s to f95 suffixes" % F95Suffixes) try: F95PPSuffixes = env['F95PPFILESUFFIXES'] except KeyError: @@ -239,7 +239,7 @@ def add_f03_to_env(env): except KeyError: F03Suffixes = ['.f03'] - #print "Adding %s to f95 suffixes" % F95Suffixes + #print("Adding %s to f95 suffixes" % F95Suffixes) try: F03PPSuffixes = env['F03PPFILESUFFIXES'] except KeyError: diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 18f154a..8212cc1 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -312,7 +312,7 @@ class PreProcessor(object): t = self.tuples.pop(0) # Uncomment to see the list of tuples being processed (e.g., # to validate the CPP lines are being translated correctly). - #print t + #print(t) self.dispatch_table[t[0]](t) return self.finalize_result(fname) @@ -510,7 +510,7 @@ class PreProcessor(object): t = self.resolve_include(t) include_file = self.find_include_file(t) if include_file: - #print "include_file =", include_file + #print("include_file =", include_file) self.result.append(include_file) contents = self.read_file(include_file) new_tuples = [('scons_current_file', include_file)] + \ @@ -547,7 +547,7 @@ class PreProcessor(object): """ s = t[1] while not s[0] in '<"': - #print "s =", s + #print("s =", s) try: s = self.cpp_namespace[s] except KeyError: -- cgit v0.12 From 201e568bed7c69fcc89229db1ed68be6ff75b3bc Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 22:40:59 -0800 Subject: Use print() function to fix py2/3 --- doc/man/scons.xml | 36 ++++++++++++++++++------------------ doc/user/builders-writing.xml | 4 ++-- doc/user/command-line.xml | 14 +++++++------- doc/user/environments.xml | 30 +++++++++++++++--------------- doc/user/misc.xml | 30 +++++++++++++++--------------- doc/user/nodes.xml | 12 ++++++------ doc/user/output.xml | 8 ++++---- doc/user/simple.xml | 6 +++--- src/engine/SCons/Environment.xml | 2 +- src/engine/SCons/Script/Main.xml | 4 ++-- 10 files changed, 73 insertions(+), 73 deletions(-) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 41ef607..b68f27a 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -2483,7 +2483,7 @@ foo = Object('foo.c') bar = Object('bar.c') objects = ['begin.o'] + foo + ['middle.o'] + bar + ['end.o'] for object in objects: - print str(object) + print(str(object)) Or you can use the @@ -2497,7 +2497,7 @@ foo = Object('foo.c') bar = Object('bar.c') objects = Flatten(['begin.o', foo, 'middle.o', bar, 'end.o']) for object in objects: - print str(object) + print(str(object)) Note also that because Builder calls return @@ -2541,7 +2541,7 @@ function: bar_obj_list = env.StaticObject('bar.c', CPPDEFINES='-DBAR') -print "The path to bar_obj is:", str(bar_obj_list[0]) +print("The path to bar_obj is:", str(bar_obj_list[0])) Note again that because the Builder call returns a list, @@ -2842,10 +2842,10 @@ of the tuple, respectively. Example: -print "first keyword, value =", ARGLIST[0][0], ARGLIST[0][1] -print "second keyword, value =", ARGLIST[1][0], ARGLIST[1][1] +print("first keyword, value =", ARGLIST[0][0], ARGLIST[0][1]) +print("second keyword, value =", ARGLIST[1][0], ARGLIST[1][1]) third_tuple = ARGLIST[2] -print "third keyword, value =", third_tuple[0], third_tuple[1] +print("third keyword, value =", third_tuple[0], third_tuple[1]) for key, value in ARGLIST: # process key and value @@ -2913,7 +2913,7 @@ for additional information. if 'foo' in BUILD_TARGETS: - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") if 'special/program' in BUILD_TARGETS: SConscript('special') @@ -2951,7 +2951,7 @@ is explicitly being built. if 'foo' in COMMAND_LINE_TARGETS: - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") if 'special/program' in COMMAND_LINE_TARGETS: SConscript('special') @@ -2975,9 +2975,9 @@ function to get at the path name for each Node. Example: -print str(DEFAULT_TARGETS[0]) +print(str(DEFAULT_TARGETS[0])) if 'foo' in map(str, DEFAULT_TARGETS): - print "Don't forget to test the `foo' program!" + print("Don't forget to test the `foo' program!") @@ -2990,13 +2990,13 @@ list change on on each successive call to the function: -print map(str, DEFAULT_TARGETS) # originally [] +print(map(str, DEFAULT_TARGETS)) # originally [] Default('foo') -print map(str, DEFAULT_TARGETS) # now a node ['foo'] +print(map(str, DEFAULT_TARGETS)) # now a node ['foo'] Default('bar') -print map(str, DEFAULT_TARGETS) # now a node ['foo', 'bar'] +print(map(str, DEFAULT_TARGETS)) # now a node ['foo', 'bar'] Default(None) -print map(str, DEFAULT_TARGETS) # back to [] +print(map(str, DEFAULT_TARGETS)) # back to [] Consequently, be sure to use @@ -3525,7 +3525,7 @@ a shared library, only that the compilation (not link) succeeds. env = Environment() conf = Configure( env ) if not conf.CheckCHeader( 'math.h' ): - print 'We really need math.h!' + print('We really need math.h!') Exit(1) if conf.CheckLibWithHeader( 'qt', 'qapp.h', 'c++', 'QApplication qapp(0,0);' ): @@ -3815,7 +3815,7 @@ int main(int argc, char **argv) { env = Environment() conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } ) if not conf.CheckQt('/usr/lib/qt'): - print 'We really need qt!' + print('We really need qt!') Exit(1) env = conf.Finish() @@ -3995,7 +3995,7 @@ not configured. env = Environment(variables=vars) for key, value in vars.UnknownVariables(): - print "unknown variable: %s=%s" % (key, value) + print("unknown variable: %s=%s" % (key, value)) @@ -4400,7 +4400,7 @@ File('foo.c').srcnode().path # source path of the given source file. # Builders also return File objects: foo = env.Program('foo.c') -print "foo will be built in %s"%foo.path +print("foo will be built in %s"%foo.path) A diff --git a/doc/user/builders-writing.xml b/doc/user/builders-writing.xml index dec176a..07f2dec 100644 --- a/doc/user/builders-writing.xml +++ b/doc/user/builders-writing.xml @@ -1047,7 +1047,7 @@ def MakeWorkDir(workdir): import my_utils MakeWorkDir('/tmp/work') -print "build_id=" + my_utils.build_id() +print("build_id=" + my_utils.build_id()) @@ -1060,7 +1060,7 @@ print "build_id=" + my_utils.build_id() import my_utils -print "build_id=" + my_utils.build_id() +print("build_id=" + my_utils.build_id()) my_utils.MakeWorkDir('/tmp/work') diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml index 85c2da0..a4bbf21 100644 --- a/doc/user/command-line.xml +++ b/doc/user/command-line.xml @@ -317,7 +317,7 @@ if not GetOption('help'): import os num_cpu = int(os.environ.get('NUM_CPU', 2)) SetOption('num_jobs', num_cpu) -print "running with -j", GetOption('num_jobs') +print("running with -j", GetOption('num_jobs')) foo.in @@ -1863,7 +1863,7 @@ env = Environment(variables = vars, CPPDEFINES={'RELEASE_BUILD' : '${RELEASE}'}) unknown = vars.UnknownVariables() if unknown: - print "Unknown variables:", unknown.keys() + print("Unknown variables:", unknown.keys()) Exit(1) env.Program('foo.c') @@ -1945,7 +1945,7 @@ foo.c if 'bar' in COMMAND_LINE_TARGETS: - print "Don't forget to copy `bar' to the archive!" + print("Don't forget to copy `bar' to the archive!") Default(Program('foo.c')) Program('bar.c') @@ -2210,7 +2210,7 @@ prog2.c prog1 = Program('prog1.c') Default(prog1) -print "DEFAULT_TARGETS is", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is", map(str, DEFAULT_TARGETS)) prog1.c @@ -2244,10 +2244,10 @@ prog1.c prog1 = Program('prog1.c') Default(prog1) -print "DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS)) prog2 = Program('prog2.c') Default(prog2) -print "DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS) +print("DEFAULT_TARGETS is now", map(str, DEFAULT_TARGETS)) prog1.c @@ -2338,7 +2338,7 @@ else: prog1 = Program('prog1.c') Program('prog2.c') Default(prog1) -print "BUILD_TARGETS is", map(str, BUILD_TARGETS) +print("BUILD_TARGETS is", map(str, BUILD_TARGETS)) prog1.c diff --git a/doc/user/environments.xml b/doc/user/environments.xml index 66abdcc..d1da3f9 100644 --- a/doc/user/environments.xml +++ b/doc/user/environments.xml @@ -627,7 +627,7 @@ int main() { } env = Environment() -print "CC is:", env['CC'] +print("CC is:", env['CC']) @@ -658,7 +658,7 @@ print "CC is:", env['CC'] env = Environment(FOO = 'foo', BAR = 'bar') dict = env.Dictionary() for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: - print "key = %s, value = %s" % (key, dict[key]) + print("key = %s, value = %s" % (key, dict[key])) @@ -695,7 +695,7 @@ for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: env = Environment() for item in sorted(env.Dictionary().items()): - print "construction variable = '%s', value = '%s'" % item + print("construction variable = '%s', value = '%s'" % item) @@ -721,7 +721,7 @@ for item in sorted(env.Dictionary().items()): env = Environment() -print "CC is:", env.subst('$CC') +print("CC is:", env.subst('$CC')) @@ -738,7 +738,7 @@ print "CC is:", env.subst('$CC') env = Environment(CCFLAGS = '-DFOO') -print "CCCOM is:", env['CCCOM'] +print("CCCOM is:", env['CCCOM']) @@ -764,7 +764,7 @@ scons: `.' is up to date. env = Environment(CCFLAGS = '-DFOO') -print "CCCOM is:", env.subst('$CCCOM') +print("CCCOM is:", env.subst('$CCCOM')) @@ -806,7 +806,7 @@ scons: `.' is up to date. env = Environment() -print "value is:", env.subst( '->$MISSING<-' ) +print("value is:", env.subst( '->$MISSING<-' )) @@ -834,7 +834,7 @@ print "value is:", env.subst( '->$MISSING<-' ) AllowSubstExceptions() env = Environment() -print "value is:", env.subst( '->$MISSING<-' ) +print("value is:", env.subst( '->$MISSING<-' )) @@ -854,7 +854,7 @@ print "value is:", env.subst( '->$MISSING<-' ) AllowSubstExceptions(IndexError, NameError, ZeroDivisionError) env = Environment() -print "value is:", env.subst( '->${1 / 0}<-' ) +print("value is:", env.subst( '->${1 / 0}<-' )) @@ -1216,7 +1216,7 @@ int main() { } env = Environment() env.Replace(NEW_VARIABLE = 'xyzzy') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1251,11 +1251,11 @@ print "NEW_VARIABLE =", env['NEW_VARIABLE'] env = Environment(CCFLAGS = '-DDEFINE1') -print "CCFLAGS =", env['CCFLAGS'] +print("CCFLAGS =", env['CCFLAGS']) env.Program('foo.c') env.Replace(CCFLAGS = '-DDEFINE2') -print "CCFLAGS =", env['CCFLAGS'] +print("CCFLAGS =", env['CCFLAGS']) env.Program('bar.c') @@ -1375,7 +1375,7 @@ int main() { } env = Environment() env.Append(NEW_VARIABLE = 'added') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1475,7 +1475,7 @@ int main() { } env = Environment() env.Prepend(NEW_VARIABLE = 'added') -print "NEW_VARIABLE =", env['NEW_VARIABLE'] +print("NEW_VARIABLE =", env['NEW_VARIABLE']) @@ -1650,7 +1650,7 @@ if len(sys.argv) > 1: else: keys = sorted(os.environ.keys()) for key in keys: - print " " + key + "=" + os.environ[key] + print(" " + key + "=" + os.environ[key]) diff --git a/doc/user/misc.xml b/doc/user/misc.xml index 286963d..1690639 100644 --- a/doc/user/misc.xml +++ b/doc/user/misc.xml @@ -212,7 +212,7 @@ SCons 1.0 or greater required, but you have SCons 0.98.5 if ARGUMENTS.get('FUTURE'): - print "The FUTURE option is not supported yet!" + print("The FUTURE option is not supported yet!") Exit(2) env = Environment() env.Program('hello.c') @@ -268,9 +268,9 @@ hello.c # one directory -print FindFile('missing', '.') +print(FindFile('missing', '.')) t = FindFile('exists', '.') -print t.__class__, t +print(t.__class__, t) exists @@ -287,7 +287,7 @@ print t.__class__, t includes = [ '.', 'include', 'src/include'] headers = [ 'nonesuch.h', 'config.h', 'private.h', 'dist.h'] for hdr in headers: - print '%-12s' % ('%s:' % hdr), FindFile(hdr, includes) + print('%-12s' % ('%s:' % hdr), FindFile(hdr, includes)) exists @@ -320,7 +320,7 @@ exists # several directories includes = [ '.', 'include', 'src/include'] headers = [ 'nonesuch.h', 'config.h', 'private.h', 'dist.h'] -print FindFile(headers, includes) +print(FindFile(headers, includes)) exists @@ -350,9 +350,9 @@ exists -print FindFile('multiple', ['sub1', 'sub2', 'sub3']) -print FindFile('multiple', ['sub2', 'sub3', 'sub1']) -print FindFile('multiple', ['sub3', 'sub1', 'sub2']) +print(FindFile('multiple', ['sub1', 'sub2', 'sub3'])) +print(FindFile('multiple', ['sub2', 'sub3', 'sub1'])) +print(FindFile('multiple', ['sub3', 'sub1', 'sub2'])) @@ -386,8 +386,8 @@ exists # Neither file exists, so build will fail Command('derived', 'leaf', 'cat >$TARGET $SOURCE') -print FindFile('leaf', '.') -print FindFile('derived', '.') +print(FindFile('leaf', '.')) +print(FindFile('derived', '.')) @@ -399,8 +399,8 @@ print FindFile('derived', '.') # Only 'leaf' exists Command('derived', 'leaf', 'cat >$TARGET $SOURCE') -print FindFile('leaf', '.') -print FindFile('derived', '.') +print(FindFile('leaf', '.')) +print(FindFile('derived', '.')) leaf @@ -422,7 +422,7 @@ leaf # Only 'src/leaf' exists VariantDir('build', 'src') -print FindFile('leaf', 'build') +print(FindFile('leaf', 'build')) @@ -507,7 +507,7 @@ objects = [ Program(objects) for object_file in objects: - print object_file.abspath + print(object_file.abspath) prog1.c @@ -548,7 +548,7 @@ objects = [ Program(objects) for object_file in Flatten(objects): - print object_file.abspath + print(object_file.abspath) prog1.c diff --git a/doc/user/nodes.xml b/doc/user/nodes.xml index a04b6ad..b17bb7c 100644 --- a/doc/user/nodes.xml +++ b/doc/user/nodes.xml @@ -265,8 +265,8 @@ xyzzy = Entry('xyzzy') object_list = Object('hello.c') program_list = Program(object_list) -print "The object file is:", object_list[0] -print "The program file is:", program_list[0] +print("The object file is:", object_list[0]) +print("The program file is:", program_list[0]) int main() { printf("Hello, world!\n"); } @@ -334,7 +334,7 @@ import os.path program_list = Program('hello.c') program_name = str(program_list[0]) if not os.path.exists(program_name): - print program_name, "does not exist!" + print(program_name, "does not exist!") int main() { printf("Hello, world!\n"); } @@ -374,7 +374,7 @@ int main() { printf("Hello, world!\n"); } env=Environment(VAR="value") n=File("foo.c") -print env.GetBuildPath([n, "sub/dir/$VAR"]) +print(env.GetBuildPath([n, "sub/dir/$VAR"])) @@ -414,8 +414,8 @@ print env.GetBuildPath([n, "sub/dir/$VAR"]) hello_c = File('hello.c') contents = hello_c.read() -print "contents are:" -print contents +print("contents are:") +print(contents) int main() { printf("Hello, world!\n"); } diff --git a/doc/user/output.xml b/doc/user/output.xml index 78dcca4..ca4707d 100644 --- a/doc/user/output.xml +++ b/doc/user/output.xml @@ -622,7 +622,7 @@ import atexit def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print "%s failed: %s" % (bf.node, bf.errstr) + print("%s failed: %s" % (bf.node, bf.errstr)) atexit.register(print_build_failures) @@ -701,10 +701,10 @@ def display_build_status(): Here you could do all kinds of complicated things.""" status, failures_message = build_status() if status == 'failed': - print "FAILED!!!!" # could display alert, ring bell, etc. + print("FAILED!!!!") # could display alert, ring bell, etc. elif status == 'ok': - print "Build succeeded." - print failures_message + print("Build succeeded.") + print(failures_message) atexit.register(display_build_status) diff --git a/doc/user/simple.xml b/doc/user/simple.xml index a015c91..acc438b 100644 --- a/doc/user/simple.xml +++ b/doc/user/simple.xml @@ -442,11 +442,11 @@ Program('hello.c') # "hello.c" is the source file. -print "Calling Program('hello.c')" +print("Calling Program('hello.c')") Program('hello.c') -print "Calling Program('goodbye.c')" +print("Calling Program('goodbye.c')") Program('goodbye.c') -print "Finished calling Program()" +print("Finished calling Program()") int main() { printf("Hello, world!\n"); } diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 65d71ff..92bc21a 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -327,7 +327,7 @@ Examples: # which the method will be called; the Python # convention is to call it 'self'. def my_method(self, arg): - print "my_method() got", arg + print("my_method() got", arg) # Use the global AddMethod() function to add a method # to the Environment class. This diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml index 07dce9a..98db5bf 100644 --- a/src/engine/SCons/Script/Main.xml +++ b/src/engine/SCons/Script/Main.xml @@ -256,7 +256,7 @@ import atexit def print_build_failures(): from SCons.Script import GetBuildFailures for bf in GetBuildFailures(): - print "%s failed: %s" % (bf.node, bf.errstr) + print("%s failed: %s" % (bf.node, bf.errstr)) atexit.register(print_build_failures) @@ -577,7 +577,7 @@ every 10 Nodes: def my_progress_function(node, *args, **kw): - print 'Evaluating node %s!' % node + print('Evaluating node %s!' % node) Progress(my_progress_function, interval=10) -- cgit v0.12 From 2ff5df2eb4e694e1c7e53fab71e0125d277c111e Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:24:12 -0800 Subject: Use syntax for octal integers as specified in PEP 3127 --- test/Chmod.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/Chmod.py b/test/Chmod.py index e5bb85f..316800b 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -36,13 +36,13 @@ import TestSCons test = TestSCons.TestSCons() # Note: Windows basically has two modes that it can os.chmod() files to -# 0444 and 0666, and directories to 0555 and 0777, so we can only really +# 0o444 and 0o666, and directories to 0o555 and 0o777, so we can only really # oscillate between those values. test.write('SConstruct', """ -Execute(Chmod('f1', 0666)) -Execute(Chmod(('f1-File'), 0666)) -Execute(Chmod('d2', 0777)) -Execute(Chmod(Dir('d2-Dir'), 0777)) +Execute(Chmod('f1', 0o666)) +Execute(Chmod(('f1-File'), 0o666)) +Execute(Chmod('d2', 0o777)) +Execute(Chmod(Dir('d2-Dir'), 0o777)) def cat(env, source, target): target = str(target[0]) f = open(target, "wb") @@ -52,18 +52,18 @@ def cat(env, source, target): Cat = Action(cat) env = Environment() env.Command('bar.out', 'bar.in', [Cat, - Chmod("f3", 0666), - Chmod("d4", 0777)]) + Chmod("f3", 0o666), + Chmod("d4", 0o777)]) env = Environment(FILE = 'f5') -env.Command('f6.out', 'f6.in', [Chmod('$FILE', 0666), Cat]) +env.Command('f6.out', 'f6.in', [Chmod('$FILE', 0o666), Cat]) env.Command('f7.out', 'f7.in', [Cat, - Chmod('Chmod-$SOURCE', 0666), - Chmod('${TARGET}-Chmod', 0666)]) + Chmod('Chmod-$SOURCE', 0o666), + Chmod('${TARGET}-Chmod', 0o666)]) # Make sure Chmod works with a list of arguments env = Environment(FILE = 'f9') -env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0666), Cat]) -Execute(Chmod(['d11', Dir('d12')], 0777)) +env.Command('f8.out', 'f8.in', [Chmod(['$FILE', File('f10')], 0o666), Cat]) +Execute(Chmod(['d11', Dir('d12')], 0o777)) Execute(Chmod('f13', "a=r")) Execute(Chmod('f14', "ogu+w")) Execute(Chmod('f15', "ug=rw, go+ rw")) -- cgit v0.12 From 48074f8237304d335e8699f5d544fdfe02eb103c Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:27:13 -0800 Subject: Use print() function to fix py2/3 --- test/VariantDir/reflect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/VariantDir/reflect.py b/test/VariantDir/reflect.py index ea5689a..72f3af7 100644 --- a/test/VariantDir/reflect.py +++ b/test/VariantDir/reflect.py @@ -44,11 +44,15 @@ _python_ = TestSCons._python_ re_python = re.escape(TestSCons._python_) test.write("mycc.py", """ -print 'Compile' +from __future__ import print_function + +print('Compile') """) test.write("mylink.py", """ -print 'Link' +from __future__ import print_function + +print('Link') """) sconstruct = """ -- cgit v0.12 From d3dbe8e9502534149b1ca175c483882f7b4e551d Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 9 Mar 2017 23:29:20 -0800 Subject: Use print() function to fix py2/3 --- test/scons-time/run/config/python.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 57b732d..2660927 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -44,13 +44,14 @@ python = r'%(my_python_py)s' test.write(my_python_py, """\ #!/usr/bin/env python +from __future__ import print_function import sys profile = '' for arg in sys.argv[1:]: if arg.startswith('--profile='): profile = arg[10:] break -print 'my_python.py: %s' % profile +print('my_python.py: %s' % profile) """) os.chmod(my_python_py, 0o755) -- cgit v0.12