diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-04-24 05:51:13 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-04-24 05:51:13 (GMT) |
commit | 7e116b31182749950856c622ca7932031f8be19c (patch) | |
tree | a4b9f900e52561a91e0c4509dc6c692492996b7f /test | |
parent | 591b78f0f314f11192fdf13d3baa66f81b160e44 (diff) | |
download | SCons-7e116b31182749950856c622ca7932031f8be19c.zip SCons-7e116b31182749950856c622ca7932031f8be19c.tar.gz SCons-7e116b31182749950856c622ca7932031f8be19c.tar.bz2 |
http://scons.tigris.org/issues/show_bug.cgi?id=2345
Comb out all code that supported earlier versions of Python. Most such
code is in snippets of only a few lines and can be identified by having
a Python version string in it. Such snippets add up; this combing pass
probably got rid of over 500 lines of code.
Diffstat (limited to 'test')
29 files changed, 15 insertions, 167 deletions
diff --git a/test/Actions/function.py b/test/Actions/function.py index 2039197..4bde525 100644 --- a/test/Actions/function.py +++ b/test/Actions/function.py @@ -158,25 +158,16 @@ scons: `.' is up to date. scons: done building targets. """ -import sys -if sys.version[:3] == '2.1': - expectedStderr = """\ -%s:79: SyntaxWarning: local name 'x' in 'a' shadows use of 'x' as global in nested scope 'b' - def a(): -""" % test.workpath('SConstruct') -else: - expectedStderr = "" - -def runtest(arguments, expectedOutFile, expectedRebuild=True, stderr=expectedStderr): +def runtest(arguments, expectedOutFile, expectedRebuild=True, stderr=""): test.run(arguments=arguments, stdout=expectedRebuild and rebuildstr or nobuildstr, - stderr=expectedStderr) + stderr="") test.must_match('Out.gen.h', expectedOutFile) - # Should not be rebuild when ran a second time with the same + # Should not be rebuild when run a second time with the same # arguments. - test.run(arguments = arguments, stdout=nobuildstr, stderr=expectedStderr) + test.run(arguments = arguments, stdout=nobuildstr, stderr="") test.must_match('Out.gen.h', expectedOutFile) diff --git a/test/AddOption/help.py b/test/AddOption/help.py index 26b9775..d50e595 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Deprecated/BuildDir.py b/test/Deprecated/BuildDir.py index e8755da..4918ac0 100644 --- a/test/Deprecated/BuildDir.py +++ b/test/Deprecated/BuildDir.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Errors/SyntaxError.py b/test/Errors/SyntaxError.py index 08539ad..1b7f650 100644 --- a/test/Errors/SyntaxError.py +++ b/test/Errors/SyntaxError.py @@ -37,10 +37,8 @@ test.write('SConstruct', """ a ! x """) -# It looks like vanilla Python 2.2 is the only version that -# puts "<string>" here in place of the file name. test.run(stdout = "scons: Reading SConscript files ...\n", - stderr = """ File "(.+SConstruct|<string>)", line 2 + stderr = """ File ".+SConstruct", line 2 a ! x diff --git a/test/Execute.py b/test/Execute.py index 409594c..4caa4c4 100644 --- a/test/Execute.py +++ b/test/Execute.py @@ -90,17 +90,7 @@ scons: *** Error 2 scons: *** nonexistent.in/*.*: The system cannot find the path specified """ else: - # TODO(1.5): the underlying shutil.copytree() call doesn't - # add the nonexistent file name to the exception it throws. - # This goes away soon, so just accomodate the difference. - if sys.version[:3] == '1.5': - expect = """\ -scons: *** Error 1 -scons: *** Error 2 -scons: *** No such file or directory -""" - else: - expect = """\ + expect = """\ scons: *** Error 1 scons: *** Error 2 scons: *** nonexistent.in: No such file or directory diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index 300f69f..a9818a6 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -67,13 +67,8 @@ def print_build_failures(): for bf in sorted(GetBuildFailures(), key=lambda a: a.filename): print "%%s failed: %%s" %% (bf.node, bf.errstr) -try: - import atexit -except ImportError: - import sys - sys.exitfunc = print_build_failures -else: - atexit.register(print_build_failures) +import atexit +atexit.register(print_build_failures) """ % locals()) test.write('f3.in', "f3.in\n") diff --git a/test/Java/Java-1.4.py b/test/Java/Java-1.4.py index c84a2f0..c1eb5e5 100644 --- a/test/Java/Java-1.4.py +++ b/test/Java/Java-1.4.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Java/Java-1.5.py b/test/Java/Java-1.5.py index 6c4ea46..0f93a00 100644 --- a/test/Java/Java-1.5.py +++ b/test/Java/Java-1.5.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/Java/Java-1.6.py b/test/Java/Java-1.6.py index d34fcca..bd7a48f 100644 --- a/test/Java/Java-1.6.py +++ b/test/Java/Java-1.6.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/LoadableModule.py b/test/LoadableModule.py index 40f9ce8..574b0cd 100644 --- a/test/LoadableModule.py +++ b/test/LoadableModule.py @@ -41,7 +41,6 @@ use_dl_lib = "env.Program(target = 'dlopenprog', source = 'dlopenprog.c', LIBS=[ dlopen_line = { 'darwin' : no_dl_lib, - 'darwin8' : no_dl_lib, # ONLY NEEDED FOR 1.5.2 'freebsd4' : no_dl_lib, 'linux2' : use_dl_lib, } diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py index 63083da..efa91be 100644 --- a/test/QT/copied-env.py +++ b/test/QT/copied-env.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/SWIG/SWIGOUTDIR-python.py b/test/SWIG/SWIGOUTDIR-python.py index 763e9c4..c94e509 100644 --- a/test/SWIG/SWIGOUTDIR-python.py +++ b/test/SWIG/SWIGOUTDIR-python.py @@ -53,11 +53,6 @@ env = Environment(SWIGFLAGS = '-python -c++', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - env.Append(SWIGFLAGS = ' -classic') - env.LoadableModule('python_foo_interface', 'python_foo_interface.i') """ % locals()) diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index a9d7cb2..4e5bfe9 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -20,7 +20,6 @@ # 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. -# __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -71,11 +70,6 @@ env = Environment(CPPPATH = [".", r'%(python_include)s'], LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - env.Append(SWIGFLAGS = '-classic') - Export("env") # diff --git a/test/SWIG/live.py b/test/SWIG/live.py index 8f580c9..4d4369e 100644 --- a/test/SWIG/live.py +++ b/test/SWIG/live.py @@ -72,11 +72,6 @@ foo = Environment(SWIGFLAGS='-python', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - foo.Append(SWIGFLAGS = ' -classic') - swig = foo.Dictionary('SWIG') bar = foo.Clone(SWIG = [r'%(python)s', 'wrapper.py', swig]) foo.LoadableModule(target = 'foo', source = ['foo.c', 'foo.i']) diff --git a/test/SWIG/module-parens.py b/test/SWIG/module-parens.py index 7886218..6ae4924 100644 --- a/test/SWIG/module-parens.py +++ b/test/SWIG/module-parens.py @@ -52,11 +52,6 @@ env = Environment(SWIGFLAGS = '-python -c++', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - env.Append(SWIGFLAGS = ' -classic') - env.LoadableModule('test1.so', ['test1.i', 'test1.cc']) env.LoadableModule('test2.so', ['test2.i', 'test2.cc']) """ % locals()) diff --git a/test/SWIG/module-quoted.py b/test/SWIG/module-quoted.py index 89402eb..ec7a132 100644 --- a/test/SWIG/module-quoted.py +++ b/test/SWIG/module-quoted.py @@ -52,11 +52,6 @@ env = Environment(SWIGFLAGS = '-python -c++', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - env.Append(SWIGFLAGS = ' -classic') - env.LoadableModule('test1.so', ['test1.i', 'test1.cc']) """ % locals()) diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py index 8ed24ef..964970b 100644 --- a/test/SWIG/remove-modules.py +++ b/test/SWIG/remove-modules.py @@ -71,11 +71,6 @@ foo = Environment(SWIGFLAGS='-python', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - foo.Append(SWIGFLAGS = ' -classic') - foo.LoadableModule(target = 'modulename', source = ['module.i']) """ % locals()) diff --git a/test/SWIG/subdir.py b/test/SWIG/subdir.py index d4798f6..0b9f24d 100644 --- a/test/SWIG/subdir.py +++ b/test/SWIG/subdir.py @@ -68,11 +68,6 @@ env = Environment(SWIGFLAGS='-python', LIBS='%(python_lib)s', ) -import sys -if sys.version[0] == '1': - # SWIG requires the -classic flag on pre-2.0 Python versions. - env.Append(SWIGFLAGS = ' -classic') - env.LoadableModule('sub/_foo', ['sub/foo.i', 'sub/foo.c'], LDMODULEPREFIX='') diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index b895caa..55e22bd 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -48,56 +48,14 @@ test.write('build.py', r""" import codecs import sys -# TODO(2.2): Remove when 2.3 becomes the minimal supported version. -try: - codecs.BOM_UTF8 -except AttributeError: - codecs.BOM_UTF8 = '\xef\xbb\xbf' -try: - codecs.BOM_UTF16_LE - codecs.BOM_UTF16_BE -except AttributeError: - codecs.BOM_UTF16_LE = '\xff\xfe' - codecs.BOM_UTF16_BE = '\xfe\xff' - -try: - ''.decode -except AttributeError: - # 2.0 through 2.2: strings have no .decode() method - try: - codecs.lookup('ascii').decode - except AttributeError: - # 2.0 and 2.1: encodings are a tuple of functions, and the - # decode() function returns a (result, length) tuple. - def my_decode(contents, encoding): - return codecs.lookup(encoding)[1](contents)[0] - else: - # 2.2: encodings are an object with methods, and the .decode() - # and .decode() returns just the decoded bytes. - def my_decode(contents, encoding): - return codecs.lookup(encoding).decode(contents) -else: - # 2.3 or later: use the .decode() string method - def my_decode(contents, encoding): - return contents.decode(encoding) - def process(outfp, infile): contents = open(infile, 'rb').read() if contents.startswith(codecs.BOM_UTF8): - contents = contents[len(codecs.BOM_UTF8):] - # TODO(2.2): Remove when 2.3 becomes the minimal supported version. - #contents = contents.decode('utf-8') - contents = my_decode(contents, 'utf-8') + contents = contents[len(codecs.BOM_UTF8):].decode('utf-8') elif contents.startswith(codecs.BOM_UTF16_LE): - contents = contents[len(codecs.BOM_UTF16_LE):] - # TODO(2.2): Remove when 2.3 becomes the minimal supported version. - #contents = contents.decode('utf-16-le') - contents = my_decode(contents, 'utf-16-le') + contents = contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') elif contents.startswith(codecs.BOM_UTF16_BE): - contents = contents[len(codecs.BOM_UTF16_BE):] - # TODO(2.2): Remove when 2.3 becomes the minimal supported version. - #contents = contents.decode('utf-16-be') - contents = my_decode(contents, 'utf-16-be') + contents = contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') for line in contents.split('\n')[:-1]: if line[:8] == 'include ': process(outfp, line[8:]) diff --git a/test/TAR/TAR.py b/test/TAR/TAR.py index 5a19a98..93c5cea 100644 --- a/test/TAR/TAR.py +++ b/test/TAR/TAR.py @@ -44,7 +44,7 @@ for opt, arg in opts: if opt == '-f': out = arg def process(outfile, name): if os.path.isdir(name): - ## TODO 2.5: the next three lines can be replaced by + ## TODO 2.4: the next three lines can be replaced by #for entry in sorted(os.listdir(name)): list = os.listdir(name) list.sort() diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index 0de3458..24d4bdd 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/VariantDir/VariantDir.py b/test/VariantDir/VariantDir.py index 7b89db4..a294d6b 100644 --- a/test/VariantDir/VariantDir.py +++ b/test/VariantDir/VariantDir.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index f9ba417..ece64af 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -49,7 +49,7 @@ import os.path import sys def process(outfile, name): if os.path.isdir(name): - ## TODO 2.5: the next three lines can be replaced by + ## TODO 2.4: the next three lines can be replaced by #for entry in sorted(os.listdir(name)): list = os.listdir(name) list.sort() diff --git a/test/builderrors.py b/test/builderrors.py index e5d8866..0133107 100644 --- a/test/builderrors.py +++ b/test/builderrors.py @@ -133,9 +133,8 @@ test.run(status=2, stderr=None) test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback']) -# Python 1.5.2 on a FC3 system doesn't even get to the exitvalmap -# because it fails with "No such file or directory." Just comment -# this out for now, there are plenty of other good tests below. +#TODO: This was originally commented out because of a problem with 1.5.2, +# but it doesn't work on later Pythons, either. #expected = [ # "too long", # posix # "nvalid argument", # win32 diff --git a/test/option/debug-count.py b/test/option/debug-count.py index c233bf5..3f8a23c 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/help-options.py b/test/option/help-options.py index 2b48a66..45bbfa0 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/option/profile.py b/test/option/profile.py index ab99dab..16032fb 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/scons-time/help/all-subcommands.py b/test/scons-time/help/all-subcommands.py index 43db3ae..03ddc46 100644 --- a/test/scons-time/help/all-subcommands.py +++ b/test/scons-time/help/all-subcommands.py @@ -20,8 +20,6 @@ # 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/test/scons-time/run/archive/zip.py b/test/scons-time/run/archive/zip.py index 2fad3b8..4620440 100644 --- a/test/scons-time/run/archive/zip.py +++ b/test/scons-time/run/archive/zip.py @@ -39,28 +39,6 @@ test.write_fake_scons_py() test.write_sample_project('foo.zip') -try: - import zipfile - # There's a bug in the Python 2.1 zipfile library that makes it blow - # up on 64-bit architectures, when trying to read normal 32-bit zip - # files. Check for it by trying to read the archive we just created, - # and skipping the test gracefully if there's a problem. - zf = zipfile.ZipFile('foo.zip', 'r') - for name in zf.namelist(): - zf.read(name) -except ImportError: - # This "shouldn't happen" because the early Python versions that - # have no zipfile module don't support the scons-time script, - # so the initialization above should short-circuit this test. - # But just in case... - fmt = "Python %s has no zipfile module. Skipping test.\n" - test.skip_test(fmt % sys.version[:3]) -except zipfile.BadZipfile, e: - if str(e)[:11] == 'Bad CRC-32 ': - fmt = "Python %s zipfile module doesn't work on 64-bit architectures. Skipping test.\n" - test.skip_test(fmt % sys.version[:3]) - raise - test.run(arguments = 'run foo.zip') test.must_exist('foo-000-0.log', |