summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2009-03-08 00:51:26 +0000
committerGreg Noel <GregNoel@tigris.org>2009-03-08 00:51:26 +0000
commitfc876e9782514b00815cd41a5cded94345b59a03 (patch)
treebeffc7420a3c8681158aeefa6b82628fa7121aca
parente67fe4c80b6c241fcb45d3e4a4387b90dae7638f (diff)
downloadscons-fc876e9782514b00815cd41a5cded94345b59a03.tar.gz
Issue 2326, change execfile() to exec ... (FIXED)
-rw-r--r--QMTest/TestSCons_time.py3
-rw-r--r--bench/bench.py3
-rw-r--r--src/engine/SCons/Variables/VariablesTests.py3
-rw-r--r--src/engine/SCons/Variables/__init__.py2
-rw-r--r--src/engine/SCons/compat/_scons_optparse.py2
-rw-r--r--src/script/scons-time.py10
-rw-r--r--test/Deprecated/Options/Options.py2
-rw-r--r--test/Deprecated/Options/chdir.py3
-rw-r--r--test/SConscript/SConscriptChdir.py15
-rw-r--r--test/SConscriptChdir.py15
-rw-r--r--test/Variables/Variables.py2
-rw-r--r--test/Variables/chdir.py3
12 files changed, 24 insertions, 39 deletions
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'], """\