Issue 2326, change execfile() to exec ... (FIXED)
authorGregNoel <GregNoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 8 Mar 2009 00:51:26 +0000 (00:51 +0000)
committerGregNoel <GregNoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 8 Mar 2009 00:51:26 +0000 (00:51 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4070 fdb21ef1-2011-0410-befe-b5e4ea1792b1

12 files changed:
QMTest/TestSCons_time.py
bench/bench.py
src/engine/SCons/Variables/VariablesTests.py
src/engine/SCons/Variables/__init__.py
src/engine/SCons/compat/_scons_optparse.py
src/script/scons-time.py
test/Deprecated/Options/Options.py
test/Deprecated/Options/chdir.py
test/SConscript/SConscriptChdir.py
test/SConscriptChdir.py
test/Variables/Variables.py
test/Variables/chdir.py

index 074739346e11efe3caa1ae12e873204ae1cf9641..f9a639eb91c72715b4869023a5ca8d4ce23ea4d5 100644 (file)
@@ -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 = """\
index d90d75ad3dc2e24dabf3aa132a1c7864061df226..ef60535033bdff3f8780a42b096666e6329b8194 100644 (file)
@@ -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:
index f1caff74a8f594d857cf39a1fc6495769bec5321..7f49692430c015ebf0c0f7306582eb6c6764e2ee 100644 (file)
@@ -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):
index 3cc6694a30d1597081456ada1093a2c428b435ea..805471a6dad31b7f1d4767525abffdcb35bd2516 100644 (file)
@@ -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]
index 23f2ad3128883a453be3175ad42a997689e583d0..219adba31fd8039d776f40fbe7b818b62045982a 100644 (file)
@@ -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):
index 019df3127436600541575cf8e25cebf03a8377dc..6e188922bca04ae3dafd3f53eed1bcff55dcb7b9 100644 (file)
@@ -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)
index f411478904bcb0c23077ffc59e881f36059922cf..d1c7114d09f5cf4c52184d886b59a0252b5e5871 100644 (file)
@@ -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
index 547fe534049285f347f9d7973d6f9c0ec8b38866..a8fb6c6bca63dd6c5a0eeaea85d0626a64eb448b 100644 (file)
@@ -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'], """\
index 8169f08fdee686abb1267109d48a0469291bda7c..4c558443eaeb19d95b9f6e764d0ca5559ad672e0 100644 (file)
@@ -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']:
index 8169f08fdee686abb1267109d48a0469291bda7c..4c558443eaeb19d95b9f6e764d0ca5559ad672e0 100644 (file)
@@ -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']:
index 0e6a152c8fc881f9cf0b7fff062cd9da0fbddb5e..a6ed74f1510dc49c3252815fa0c26f1bb1c78bd2 100644 (file)
@@ -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
index 39eccb3eede844efb2c4465d85b87b9a85f89a15..621e166034be1e9f7d4a562b4df748cbdc6a04b8 100644 (file)
@@ -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'], """\