From: GregNoel Date: Sun, 8 Mar 2009 00:51:26 +0000 (+0000) Subject: Issue 2326, change execfile() to exec ... (FIXED) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bfc1f15cc531b3fad5fa0b8cb961c1d6945cc6e0;p=scons.git Issue 2326, change execfile() to exec ... (FIXED) git-svn-id: http://scons.tigris.org/svn/scons/trunk@4070 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py index 07473934..f9a639eb 100644 --- a/QMTest/TestSCons_time.py +++ b/QMTest/TestSCons_time.py @@ -46,7 +46,6 @@ scons_py = """\ #!/usr/bin/env python import os import sys -import string def write_args(fp, args): fp.write(args[0] + '\\n') for arg in args[1:]: @@ -59,7 +58,7 @@ for arg in sys.argv[1:]: write_args(profile, sys.argv) break sys.stdout.write('SCONS_LIB_DIR = ' + os.environ['SCONS_LIB_DIR'] + '\\n') -exec(string.replace(open('SConstruct').read(), '\\r', '\\n')) +exec(open('SConstruct', 'rU').read()) """ aegis_py = """\ diff --git a/bench/bench.py b/bench/bench.py index d90d75ad..ef605350 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -28,7 +28,6 @@ import getopt import sys import time import types -import string Usage = """\ Usage: bench.py OPTIONS file.py @@ -88,7 +87,7 @@ if len(args) != 1: sys.exit(1) -exec(string.replace(open(args[0]).read(), '\r', '\n')) +exec(open(args[0], 'rU').read()) try: diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index f1caff74..7f496924 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -23,7 +23,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import string import sys import unittest import TestSCons @@ -54,7 +53,7 @@ def check(key, value, env): def checkSave(file, expected): gdict = {} ldict = {} - exec string.replace(open(file).read(), '\r', '\n') in gdict, ldict + exec open(file, 'rU').read() in gdict, ldict assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) class VariablesTestCase(unittest.TestCase): diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index 3cc6694a..805471a6 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -166,7 +166,7 @@ class Variables: sys.path.insert(0, dir) try: values['__name__'] = filename - exec string.replace(open(filename).read(), '\r', '\n') in {}, values + exec open(filename, 'rU').read() in {}, values finally: if dir: del sys.path[0] diff --git a/src/engine/SCons/compat/_scons_optparse.py b/src/engine/SCons/compat/_scons_optparse.py index 23f2ad31..219adba3 100644 --- a/src/engine/SCons/compat/_scons_optparse.py +++ b/src/engine/SCons/compat/_scons_optparse.py @@ -920,7 +920,7 @@ class Values: def read_file(self, filename, mode="careful"): vars = {} - exec string.replace(open(filename).read(), '\r', '\n') in vars + exec open(filename, 'rU').read() in vars self._update(vars, mode) def ensure_value(self, attr, value): diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 019df312..6e188922 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -841,7 +841,7 @@ class SConsTimer: self.title = a if self.config_file: - exec string.replace(open(self.config_file).read(), '\r', '\n') in self.__dict__ + exec open(self.config_file, 'rU').read() in self.__dict__ if self.chdir: os.chdir(self.chdir) @@ -960,7 +960,7 @@ class SConsTimer: self.title = a if self.config_file: - HACK_for_exec(string.replace(open(self.config_file).read(), '\r', '\n'), self.__dict__) + HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -1080,7 +1080,7 @@ class SConsTimer: object_name = args.pop(0) if self.config_file: - HACK_for_exec(string.replace(open(self.config_file).read(), '\r', '\n'), self.__dict__) + HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -1218,7 +1218,7 @@ class SConsTimer: sys.exit(1) if self.config_file: - exec string.replace(open(self.config_file).read(), '\r', '\n') in self.__dict__ + exec open(self.config_file, 'rU').read() in self.__dict__ if args: self.archive_list = args @@ -1458,7 +1458,7 @@ class SConsTimer: which = a if self.config_file: - HACK_for_exec(string.replace(open(self.config_file).read(), '\r', '\n'), self.__dict__) + HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__) if self.chdir: os.chdir(self.chdir) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index f4114789..d1c7114d 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -241,7 +241,7 @@ opts.Save('options.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec string.replace(open(file).read(), '\r', '\n') in gdict, ldict + exec open(file, 'rU').read() in gdict, ldict assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line options diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py index 547fe534..a8fb6c6b 100644 --- a/test/Deprecated/Options/chdir.py +++ b/test/Deprecated/Options/chdir.py @@ -52,8 +52,7 @@ print "VARIABLE =", repr(env['VARIABLE']) test.write(['bin', 'opts.cfg'], """\ import os os.chdir(os.path.split(__name__)[0]) -import string -exec(string.replace(open('opts2.cfg').read(), '\\r', '\\n')) +exec(open('opts2.cfg', 'rU').read()) """) test.write(['bin', 'opts2.cfg'], """\ diff --git a/test/SConscript/SConscriptChdir.py b/test/SConscript/SConscriptChdir.py index 8169f08f..4c558443 100644 --- a/test/SConscript/SConscriptChdir.py +++ b/test/SConscript/SConscriptChdir.py @@ -44,32 +44,27 @@ SConscript('dir5/SConscript') """) test.write(['dir1', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir2', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir3', 'SConscript'], """ import os.path name = os.path.join('dir3', 'create_test.py') -import string -exec(string.replace(open(name).read(), '\\r', '\\n')) +exec(open(name, 'rU').read()) """) test.write(['dir4', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir5', 'SConscript'], """ import os.path name = os.path.join('dir5', 'create_test.py') -import string -exec(string.replace(open(name).read(), '\\r', '\\n')) +exec(open(name, 'rU').read()) """) for dir in ['dir1', 'dir2', 'dir3','dir4', 'dir5']: diff --git a/test/SConscriptChdir.py b/test/SConscriptChdir.py index 8169f08f..4c558443 100644 --- a/test/SConscriptChdir.py +++ b/test/SConscriptChdir.py @@ -44,32 +44,27 @@ SConscript('dir5/SConscript') """) test.write(['dir1', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir2', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir3', 'SConscript'], """ import os.path name = os.path.join('dir3', 'create_test.py') -import string -exec(string.replace(open(name).read(), '\\r', '\\n')) +exec(open(name, 'rU').read()) """) test.write(['dir4', 'SConscript'], """ -import string -exec(string.replace(open("create_test.py").read(), '\\r', '\\n')) +exec(open("create_test.py", 'rU').read()) """) test.write(['dir5', 'SConscript'], """ import os.path name = os.path.join('dir5', 'create_test.py') -import string -exec(string.replace(open(name).read(), '\\r', '\\n')) +exec(open(name, 'rU').read()) """) for dir in ['dir1', 'dir2', 'dir3','dir4', 'dir5']: diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 0e6a152c..a6ed74f1 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -235,7 +235,7 @@ opts.Save('variables.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec string.replace(open(file).read(), '\r', '\n') in gdict, ldict + exec open(file, 'rU').read() in gdict, ldict assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line variables diff --git a/test/Variables/chdir.py b/test/Variables/chdir.py index 39eccb3e..621e1660 100644 --- a/test/Variables/chdir.py +++ b/test/Variables/chdir.py @@ -52,8 +52,7 @@ print "VARIABLE =", repr(env['VARIABLE']) test.write(['bin', 'opts.cfg'], """\ import os os.chdir(os.path.split(__name__)[0]) -import string -exec(string.replace(open('opts2.cfg').read(), '\\r', '\\n')) +exec(open('opts2.cfg', 'rU').read()) """) test.write(['bin', 'opts2.cfg'], """\