From 7c651e273c4db37f4babd91aaecf26800c50dd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Thu, 28 Sep 2017 10:21:20 +0200 Subject: New upstream version 3.0.0 --- engine/SCons/Script/SConscript.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'engine/SCons/Script/SConscript.py') diff --git a/engine/SCons/Script/SConscript.py b/engine/SCons/Script/SConscript.py index a9b2d57..350772e 100644 --- a/engine/SCons/Script/SConscript.py +++ b/engine/SCons/Script/SConscript.py @@ -5,8 +5,10 @@ files. """ +from __future__ import print_function + # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,9 +28,8 @@ files. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import division -__revision__ = "src/engine/SCons/Script/SConscript.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +__revision__ = "src/engine/SCons/Script/SConscript.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons import SCons.Action @@ -69,7 +70,7 @@ def get_calling_namespaces(): """Return the locals and globals for the function that called into this module in the current call stack.""" try: 1//0 - except ZeroDivisionError: + except ZeroDivisionError: # Don't start iterating with the current stack-frame to # prevent creating reference cycles (f_back is safe). frame = sys.exc_info()[2].tb_frame.f_back @@ -103,7 +104,7 @@ def compute_exports(exports): retval[export] = loc[export] except KeyError: retval[export] = glob[export] - except KeyError, x: + except KeyError as x: raise SCons.Errors.UserError("Export of non-existent variable '%s'"%x) return retval @@ -135,7 +136,7 @@ def Return(*vars, **kw): for var in fvars: for v in var.split(): retval.append(call_stack[-1].globals[v]) - except KeyError, x: + except KeyError as x: raise SCons.Errors.UserError("Return of non-existent variable '%s'"%x) if len(retval) == 1: @@ -164,7 +165,7 @@ def _SConscript(fs, *files, **kw): try: SCons.Script.sconscript_reading = SCons.Script.sconscript_reading + 1 if fn == "-": - exec sys.stdin in call_stack[-1].globals + exec(sys.stdin.read(), call_stack[-1].globals) else: if isinstance(fn, SCons.Node.Node): f = fn @@ -178,10 +179,10 @@ def _SConscript(fs, *files, **kw): fs.chdir(top, change_os_dir=1) if f.rexists(): actual = f.rfile() - _file_ = open(actual.get_abspath(), "r") + _file_ = open(actual.get_abspath(), "rb") elif f.srcnode().rexists(): actual = f.srcnode().rfile() - _file_ = open(actual.get_abspath(), "r") + _file_ = open(actual.get_abspath(), "rb") elif f.has_src_builder(): # The SConscript file apparently exists in a source # code management system. Build it, but then clear @@ -191,7 +192,7 @@ def _SConscript(fs, *files, **kw): f.built() f.builder_set(None) if f.exists(): - _file_ = open(f.get_abspath(), "r") + _file_ = open(f.get_abspath(), "rb") if _file_: # Chdir to the SConscript directory. Use a path # name relative to the SConstruct file so that if @@ -247,7 +248,9 @@ def _SConscript(fs, *files, **kw): pass try: try: - exec _file_ in call_stack[-1].globals +# _file_ = SCons.Util.to_str(_file_) + exec(compile(_file_.read(), _file_.name, 'exec'), + call_stack[-1].globals) except SConscriptReturn: pass finally: @@ -272,7 +275,7 @@ def _SConscript(fs, *files, **kw): rdir._create() # Make sure there's a directory there. try: os.chdir(rdir.get_abspath()) - except OSError, e: + except OSError as e: # We still couldn't chdir there, so raise the error, # but only if actions are being executed. # @@ -462,15 +465,15 @@ class SConsEnvironment(SCons.Environment.Base): scons_ver_string = '%d.%d.%d' % (major, minor, revision) else: scons_ver_string = '%d.%d' % (major, minor) - print "SCons %s or greater required, but you have SCons %s" % \ - (scons_ver_string, SCons.__version__) + print("SCons %s or greater required, but you have SCons %s" % \ + (scons_ver_string, SCons.__version__)) sys.exit(2) def EnsurePythonVersion(self, major, minor): """Exit abnormally if the Python version is not late enough.""" if sys.version_info < (major, minor): v = sys.version.split()[0] - print "Python %d.%d or greater required, but you have Python %s" %(major,minor,v) + print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v)) sys.exit(2) def Exit(self, value=0): @@ -509,7 +512,7 @@ class SConsEnvironment(SCons.Environment.Base): globals[v] = exports[v] else: globals[v] = global_exports[v] - except KeyError,x: + except KeyError as x: raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x) def SConscript(self, *ls, **kw): -- cgit v1.2.3