From 7e116b31182749950856c622ca7932031f8be19c Mon Sep 17 00:00:00 2001 From: Greg Noel Date: Sat, 24 Apr 2010 05:51:13 +0000 Subject: 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. --- QMTest/TestCmd.py | 19 +- QMTest/TestCommon.py | 1 - QMTest/TestSCons.py | 35 +-- QMTest/scons_tdb.py | 1 - QMTest/unittest.py | 1 - README | 33 +-- README-local | 2 +- SConstruct | 2 - bench/bench.py | 1 - bench/is_types.py | 52 +--- bench/timeit.py | 8 +- bin/SConsDoc.py | 1 - bin/install_python.py | 25 -- bin/linecount.py | 2 - bin/scons-doc.py | 6 +- bin/sconsexamples.py | 7 +- bootstrap.py | 6 +- debian/control | 4 +- doc/SConscript | 2 - doc/man/scons.1 | 18 +- doc/python10/process.xml | 2 +- doc/user/build-install.in | 17 +- doc/user/build-install.xml | 17 +- doc/user/builders-built-in.in | 13 - doc/user/builders-built-in.xml | 13 - doc/user/misc.in | 4 +- doc/user/misc.xml | 4 +- doc/user/tasks.in | 29 -- doc/user/tasks.xml | 29 -- gentoo/scons.ebuild.in | 2 +- rpm/scons.spec.in | 2 +- runtest.py | 2 - src/README.txt | 34 +-- src/engine/SCons/Action.py | 10 - src/engine/SCons/ActionTests.py | 8 +- src/engine/SCons/Builder.py | 2 - src/engine/SCons/BuilderTests.py | 19 +- src/engine/SCons/Debug.py | 31 +- src/engine/SCons/Environment.py | 52 +--- src/engine/SCons/EnvironmentTests.py | 68 ++--- src/engine/SCons/Errors.py | 4 +- src/engine/SCons/Executor.py | 11 +- src/engine/SCons/Job.py | 4 +- src/engine/SCons/JobTests.py | 2 - src/engine/SCons/Node/FS.py | 109 ++----- src/engine/SCons/Node/FSTests.py | 18 +- src/engine/SCons/Node/NodeTests.py | 13 +- src/engine/SCons/Node/__init__.py | 17 +- src/engine/SCons/SConf.py | 5 +- src/engine/SCons/Scanner/Dir.py | 2 - src/engine/SCons/Scanner/Fortran.py | 2 - src/engine/SCons/Scanner/LaTeX.py | 26 +- src/engine/SCons/Scanner/ScannerTests.py | 11 +- src/engine/SCons/Script/Interactive.py | 2 - src/engine/SCons/Script/Main.py | 13 +- src/engine/SCons/Script/SConsOptions.py | 7 +- src/engine/SCons/Script/SConscript.py | 2 - src/engine/SCons/Script/__init__.py | 5 +- src/engine/SCons/Subst.py | 9 +- src/engine/SCons/SubstTests.py | 10 +- src/engine/SCons/Taskmaster.py | 27 +- src/engine/SCons/Tool/MSCommon/common.py | 2 - src/engine/SCons/Tool/MSCommon/netframework.py | 2 - src/engine/SCons/Tool/MSCommon/vs.py | 6 - src/engine/SCons/Tool/__init__.py | 2 - src/engine/SCons/Tool/dvipdf.py | 2 - src/engine/SCons/Tool/ipkg.py | 3 - src/engine/SCons/Tool/javac.py | 2 - src/engine/SCons/Tool/msvs.py | 13 - src/engine/SCons/Tool/packaging/__init__.py | 2 - src/engine/SCons/Tool/packaging/msi.py | 2 - src/engine/SCons/Tool/packaging/rpm.py | 2 - src/engine/SCons/Tool/tex.py | 7 +- src/engine/SCons/Tool/zip.xml | 5 +- src/engine/SCons/Util.py | 393 ++++++++----------------- src/engine/SCons/UtilTests.py | 2 +- src/engine/SCons/Variables/ListVariable.py | 2 - src/engine/SCons/Variables/__init__.py | 20 +- src/engine/SCons/compat/_scons_hashlib.py | 19 +- src/engine/SCons/cpp.py | 11 +- src/script/scons-time.py | 1 - src/script/sconsign.py | 2 - src/setup.py | 2 - src/test_aegistests.py | 2 - src/test_interrupts.py | 2 - src/test_pychecker.py | 2 - test/Actions/function.py | 17 +- test/AddOption/help.py | 2 - test/Deprecated/BuildDir.py | 2 - test/Errors/SyntaxError.py | 4 +- test/Execute.py | 12 +- test/GetBuildFailures/option-k.py | 9 +- test/Java/Java-1.4.py | 2 - test/Java/Java-1.5.py | 2 - test/Java/Java-1.6.py | 2 - test/LoadableModule.py | 1 - test/QT/copied-env.py | 2 - test/SWIG/SWIGOUTDIR-python.py | 5 - test/SWIG/build-dir.py | 6 - test/SWIG/live.py | 5 - test/SWIG/module-parens.py | 5 - test/SWIG/module-quoted.py | 5 - test/SWIG/remove-modules.py | 5 - test/SWIG/subdir.py | 5 - test/Scanner/unicode.py | 48 +-- test/TAR/TAR.py | 2 +- test/TEX/TEX.py | 2 - test/VariantDir/VariantDir.py | 2 - test/ZIP/ZIP.py | 2 +- test/builderrors.py | 5 +- test/option/debug-count.py | 2 - test/option/help-options.py | 2 - test/option/profile.py | 2 - test/scons-time/help/all-subcommands.py | 2 - test/scons-time/run/archive/zip.py | 22 -- 115 files changed, 305 insertions(+), 1268 deletions(-) diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 0d07be6..301e5a6 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -213,7 +213,6 @@ version. # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __author__ = "Steven Knight " __revision__ = "TestCmd.py 0.37.D001 2010/01/11 16:55:50 knight" @@ -293,8 +292,6 @@ re_space = re.compile('\s') _Cleanup = [] -_chain_to_exitfunc = None - def _clean(): global _Cleanup cleanlist = [_f for _f in _Cleanup if _f] @@ -302,20 +299,8 @@ def _clean(): cleanlist.reverse() for test in cleanlist: test.cleanup() - if _chain_to_exitfunc: - _chain_to_exitfunc() - -try: - import atexit -except ImportError: - # TODO(1.5): atexit requires python 2.0, so chain sys.exitfunc - try: - _chain_to_exitfunc = sys.exitfunc - except AttributeError: - pass - sys.exitfunc = _clean -else: - atexit.register(_clean) +import atexit +atexit.register(_clean) def _caller(tblist, skip): string = "" diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 0bc2429..fce0fc8 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -88,7 +88,6 @@ The TestCommon module also provides the following variables # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __author__ = "Steven Knight " __revision__ = "TestCommon.py 0.37.D001 2010/01/11 16:55:50 knight" diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index a8bfd46..e35cbfe 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -13,7 +13,6 @@ attributes defined in this subclass. """ # __COPYRIGHT__ -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -407,8 +406,6 @@ class TestSCons(TestCommon): kw['arguments'] = option + arguments else: kw['arguments'] = option + ' ' + arguments - # TODO(1.5) - #return self.run(**kw) return self.run(**kw) def diff_substr(self, expect, actual, prelen=20, postlen=40): @@ -1045,8 +1042,6 @@ class TimeSCons(TestSCons): if 'verbose' not in kw and not self.calibrate: kw['verbose'] = True - # TODO(1.5) - #TestSCons.__init__(self, *args, **kw) TestSCons.__init__(self, *args, **kw) # TODO(sgk): better way to get the script dir than sys.argv[0] @@ -1080,15 +1075,9 @@ class TimeSCons(TestSCons): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: - # TODO(1.5) - #self.calibration(*args, **kw) self.calibration(*args, **kw) else: self.uptime() - # TODO(1.5) - #self.startup(*args, **kw) - #self.full(*args, **kw) - #self.null(*args, **kw) self.startup(*args, **kw) self.full(*args, **kw) self.null(*args, **kw) @@ -1109,8 +1098,6 @@ class TimeSCons(TestSCons): "seconds", sort=0) for name, args in stats.items(): - # TODO(1.5) - #self.trace(name, trace, *args) self.trace(name, trace, **args) def uptime(self): @@ -1150,8 +1137,6 @@ class TimeSCons(TestSCons): # won't report any statistics for it, but we can still execute # the full and null builds. kw['status'] = None - # TODO(1.5) - #self.run(*args, **kw) self.run(*args, **kw) sys.stdout.write(self.stdout()) stats = self.collect_stats(self.stdout()) @@ -1164,16 +1149,10 @@ class TimeSCons(TestSCons): """ Runs a full build of SCons. """ - # TODO(1.5) - #self.run(*args, **kw) self.run(*args, **kw) sys.stdout.write(self.stdout()) stats = self.collect_stats(self.stdout()) self.report_traces('full', stats) - # TODO(1.5) - #self.trace('full-memory', 'initial', **stats['memory-initial']) - #self.trace('full-memory', 'prebuild', **stats['memory-prebuild']) - #self.trace('full-memory', 'final', **stats['memory-final']) self.trace('full-memory', 'initial', **stats['memory-initial']) self.trace('full-memory', 'prebuild', **stats['memory-prebuild']) self.trace('full-memory', 'final', **stats['memory-final']) @@ -1184,8 +1163,6 @@ class TimeSCons(TestSCons): information (the variable(s) that were set for this configuration, and the elapsed time to run. """ - # TODO(1.5) - #self.run(*args, **kw) self.run(*args, **kw) if self.variables: for variable, value in self.variables.items(): @@ -1198,11 +1175,7 @@ class TimeSCons(TestSCons): """ # TODO(sgk): allow the caller to specify the target (argument) # that must be up-to-date. - # TODO(1.5) - #self.up_to_date(arguments='.', **kw) - kw = kw.copy() - kw['arguments'] = '.' - self.up_to_date(**kw) + self.up_to_date(arguments='.', **kw) sys.stdout.write(self.stdout()) stats = self.collect_stats(self.stdout()) # time-commands should always be 0.0 on a null build, because @@ -1213,10 +1186,6 @@ class TimeSCons(TestSCons): if float(stats['time-commands']['value']) == 0.0: del stats['time-commands'] self.report_traces('null', stats) - # TODO(1.5) - #self.trace('null-memory', 'initial', **stats['memory-initial']) - #self.trace('null-memory', 'prebuild', **stats['memory-prebuild']) - #self.trace('null-memory', 'final', **stats['memory-final']) self.trace('null-memory', 'initial', **stats['memory-initial']) self.trace('null-memory', 'prebuild', **stats['memory-prebuild']) self.trace('null-memory', 'final', **stats['memory-final']) @@ -1239,8 +1208,6 @@ class TimeSCons(TestSCons): kw['options'] = kw.get('options', '') + ' --debug=memory --debug=time' self.startTime = time.time() try: - # TODO(1.5) - #result = TestSCons.run(self, *args, **kw) result = TestSCons.run(self, *args, **kw) finally: self.endTime = time.time() diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index e56af3d..e2c40df 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -27,7 +27,6 @@ QMTest classes to support SCons' testing and Aegis-inspired workflow. Thanks to Stefan Seefeld for the initial code. """ -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/QMTest/unittest.py b/QMTest/unittest.py index 4a4433e..da2bf00 100644 --- a/QMTest/unittest.py +++ b/QMTest/unittest.py @@ -28,7 +28,6 @@ PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __author__ = "Steve Purcell (stephen_purcell@yahoo.com)" __version__ = "$ Revision: 1.23 $"[11:-2] diff --git a/README b/README index efb7c08..faa48dd 100644 --- a/README +++ b/README @@ -48,7 +48,7 @@ latest version at the SCons download page: EXECUTION REQUIREMENTS ====================== -Running SCons requires Python version 1.5.2 or later. There should be +Running SCons requires Python version 2.4 or later. There should be no other dependencies or requirements to run SCons. The default SCons configuration assumes use of the Microsoft Visual C++ @@ -67,36 +67,7 @@ configuration of Environment construction variables. INSTALLATION REQUIREMENTS ========================= -Building and installing SCons from this package requires the Python -distutils package. The distutils package was not shipped as a standard -part of Python until Python version 1.6, so if your system is running -Python 1.5.2, you may not have distutils installed. If you are running -Python version 1.6 or later, you should be fine. - -NOTE TO RED HAT USERS: Red Hat shipped Python 1.5.2 as the default all -the way up to Red Hat Linux 7.3, so you probably do *not* have distutils -installed, unless you have already done so manually or are running Red -Hat 8.0 or later. - -In this case, your options are: - - -- (Optional.) Install from a pre-packaged SCons package that - does not require distutils: - - Red Hat Linux scons-1.3.0.noarch.rpm - - Debian GNU/Linux use apt-get to get the official package - - Windows scons-1.3.0.win32.exe - - -- (Recommended.) Download the latest distutils package from the - following URL: - - http://www.python.org/sigs/distutils-sig/download.html - - Install the distutils according to the instructions on the page. - You can then proceed to the next section to install SCons from - this package. +Nothing special. INSTALLATION diff --git a/README-local b/README-local index efb9c90..fac11f1 100644 --- a/README-local +++ b/README-local @@ -44,7 +44,7 @@ scons-local package, or any SCons package, at the SCons download page: EXECUTION REQUIREMENTS ====================== -Running SCons requires Python version 1.5.2 or later. There should be +Running SCons requires Python version 2.4 or later. There should be no other dependencies or requirements to run SCons. The default SCons configuration assumes use of the Microsoft Visual C++ diff --git a/SConstruct b/SConstruct index 605f43f..32178fb 100644 --- a/SConstruct +++ b/SConstruct @@ -2,8 +2,6 @@ # SConstruct file to build scons packages during development. # # See the README file for an overview of how SCons is built and tested. -# -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS # When this gets changed, you must also change the copyright_years string # in QMTest/TestSCons.py so the test scripts look for the right string. diff --git a/bench/bench.py b/bench/bench.py index a839ed6..3391f9d 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -23,7 +23,6 @@ # # This will allow (as much as possible) us to time just the code itself, # not Python function call overhead. -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS import getopt import sys diff --git a/bench/is_types.py b/bench/is_types.py index 9cc397e..0353dc8 100644 --- a/bench/is_types.py +++ b/bench/is_types.py @@ -7,57 +7,7 @@ import types from UserDict import UserDict from UserList import UserList - -try: - from UserString import UserString -except ImportError: - # "Borrowed" from the Python 2.2 UserString module - # and modified slightly for use with SCons. - class UserString: - def __init__(self, seq): - if isinstance(seq, str): - self.data = seq - elif isinstance(seq, UserString): - self.data = seq.data[:] - else: - self.data = str(seq) - def __str__(self): return str(self.data) - def __repr__(self): return repr(self.data) - def __int__(self): return int(self.data) - def __long__(self): return long(self.data) - def __float__(self): return float(self.data) - def __complex__(self): return complex(self.data) - def __hash__(self): return hash(self.data) - - def __cmp__(self, s): - if isinstance(s, UserString): - return cmp(self.data, s.data) - else: - return cmp(self.data, s) - def __contains__(self, char): - return char in self.data - - def __len__(self): return len(self.data) - def __getitem__(self, index): return self.__class__(self.data[index]) - def __getslice__(self, start, end): - start = max(start, 0); end = max(end, 0) - return self.__class__(self.data[start:end]) - - def __add__(self, other): - if isinstance(other, UserString): - return self.__class__(self.data + other.data) - elif is_String(other): - return self.__class__(self.data + other) - else: - return self.__class__(self.data + str(other)) - def __radd__(self, other): - if is_String(other): - return self.__class__(other + self.data) - else: - return self.__class__(str(other) + self.data) - def __mul__(self, n): - return self.__class__(self.data*n) - __rmul__ = __mul__ +from UserString import UserString InstanceType = types.InstanceType DictType = dict diff --git a/bench/timeit.py b/bench/timeit.py index ca7e470..199b7c9 100644 --- a/bench/timeit.py +++ b/bench/timeit.py @@ -43,12 +43,8 @@ cases. On Unix, you can use clock() to measure CPU time. Note: there is a certain baseline overhead associated with executing a pass statement. The code here doesn't try to hide it, but you should be aware of it. The baseline overhead can be measured by invoking the -program without arguments. - -The baseline overhead differs between Python versions! Also, to -fairly compare older Python versions to Python 2.3, you may want to -use python -O for the older versions to avoid timing SET_LINENO -instructions. +program without arguments. The baseline overhead differs between +Python versions! """ try: diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 4429fd2..a82e821 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -2,7 +2,6 @@ # # Module for handling SCons documentation processing. # -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __doc__ = """ This module parses home-brew XML files that document various things diff --git a/bin/install_python.py b/bin/install_python.py index ca1c8b7..86807af 100644 --- a/bin/install_python.py +++ b/bin/install_python.py @@ -15,10 +15,6 @@ import sys from Command import CommandRunner, Usage all_versions = [ - #'1.5.2', # no longer available at python.org - '2.0.1', - '2.1.3', - '2.2', '2.3.7', '2.4.5', #'2.5.2', @@ -89,16 +85,6 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] tar_gz = os.path.join(downloads_dir, python + '.tgz') tar_gz_url = os.path.join(downloads_url, version, python + '.tgz') - if (version.startswith('1.5') or - version.startswith('1.6') or - version.startswith('2.0')): - - configureflags = '--with-threads' - - else: - - configureflags = '' - cmd.subst_dictionary(locals()) if not os.path.exists(tar_gz): @@ -110,17 +96,6 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] cmd.run('cd %(python)s') - if (version.startswith('1.6') or - version.startswith('2.0')): - - def edit_modules_setup_in(): - content = open('Modules/Setup.in', 'r').read() - content = content.replace('\n#zlib', '\nzlib') - open('Modules/Setup.in', 'w').write(content) - - display = 'ed Modules/Setup.in <&1 | tee configure.out') cmd.run('make 2>&1 | tee make.out') cmd.run('%(sudo)s make install') diff --git a/bin/linecount.py b/bin/linecount.py index b433284..7dd4c20 100644 --- a/bin/linecount.py +++ b/bin/linecount.py @@ -21,8 +21,6 @@ # in each category, the number of non-blank lines, and the number of # non-comment lines. The last figure (non-comment) lines is the most # interesting one for most purposes. -# -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/bin/scons-doc.py b/bin/scons-doc.py index 7e49cbe..e5b2986 100644 --- a/bin/scons-doc.py +++ b/bin/scons-doc.py @@ -88,7 +88,6 @@ # Error output gets passed through to your error output so you # can see if there are any problems executing the command. # -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS import optparse import os @@ -501,14 +500,11 @@ def ExecuteCommand(args, c, t, dict): return func(args[1:], c, t, dict) class MySGML(sgmllib.SGMLParser): - """A subclass of the standard Python 2.2 sgmllib SGML parser. + """A subclass of the standard Python sgmllib SGML parser. This extends the standard sgmllib parser to recognize, and do cool stuff with, the added tags that describe our SCons examples, commands, and other stuff. - - Note that this doesn't work with the 1.5.2 sgmllib module, because - that didn't have the ability to work with ENTITY declarations. """ def __init__(self, outfp): sgmllib.SGMLParser.__init__(self) diff --git a/bin/sconsexamples.py b/bin/sconsexamples.py index 6f20ae9..c2768c9 100644 --- a/bin/sconsexamples.py +++ b/bin/sconsexamples.py @@ -66,8 +66,6 @@ # output from SCons, and insert it into the text as appropriate. # Error output gets passed through to your error output so you # can see if there are any problems executing the command. -# -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS import os import os.path @@ -222,10 +220,7 @@ SConscript('SConstruct') """ class MySGML(sgmllib.SGMLParser): - """A subclass of the standard Python 2.2 sgmllib SGML parser. - - Note that this doesn't work with the 1.5.2 sgmllib module, because - that didn't have the ability to work with ENTITY declarations. + """A subclass of the standard Python sgmllib SGML parser. """ def __init__(self): sgmllib.SGMLParser.__init__(self) diff --git a/bootstrap.py b/bootstrap.py index 37e8e70..a04dbc8 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -79,11 +79,7 @@ executing it for the full build of all the packages, as specified in our local SConstruct file. """ -try: - script_dir = os.path.abspath(os.path.dirname(__file__)) -except NameError: - # Pre-2.3 versions of Python don't have __file__. - script_dir = os.path.abspath(os.path.dirname(sys.argv[0])) +script_dir = os.path.abspath(os.path.dirname(__file__)) bootstrap_dir = os.path.join(script_dir, 'bootstrap') diff --git a/debian/control b/debian/control index ab360e6..c8ebf4c 100644 --- a/debian/control +++ b/debian/control @@ -2,12 +2,12 @@ Source: scons Section: devel Priority: optional Maintainer: Moshe Zadka -Build-Depends-Indep: debhelper (>> 2.0.0), python-dev (>> 2.2) +Build-Depends-Indep: debhelper (>> 2.0.0), python-dev (>> 2.4) Standards-Version: 3.5.6 Package: scons Architecture: all -Depends: python (>> 2.2) +Depends: python (>> 2.4) Description: A replacement for Make SCons is an Open Source software construction tool--that is, a build tool; an improved substitute for the classic Make utility; a better diff --git a/doc/SConscript b/doc/SConscript index 7af3d33..e22aec0 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -23,8 +23,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 import os.path import re diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 3a47547..51b2ac1 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -380,7 +380,7 @@ try to access a list member that does not exist. .B scons -requires Python version 1.5.2 or later. +requires Python version 2.4 or later. There should be no other dependencies or requirements to run .B scons. @@ -591,10 +591,9 @@ Print how many objects are created of the various classes used internally by SCons before and after reading the SConscript files and before and after building targets. -This is not supported when run under Python versions earlier than 2.1, -when SCons is executed with the Python +This is not supported when SCons is executed with the Python .B -O -(optimized) option, +(optimized) option or when the SCons modules have been compiled with optimization (that is, when executing from @@ -642,7 +641,6 @@ Prints a summary of hits and misses using the Memoizer, an internal subsystem that counts how often SCons uses cached values in memory instead of recomputing them each time they're needed. -Only available when using Python 2.2 or later. .TP --debug=memory @@ -658,7 +656,6 @@ A deprecated option preserved for backwards compatibility. --debug=objects Prints a list of the various objects of the various classes used internally by SCons. -This only works when run under Python 2.1 or later. .TP --debug=pdb @@ -2446,13 +2443,6 @@ method (with a few additional capabilities noted below); see the documentation for .B optparse for a thorough discussion of its option-processing capabities. -(Note that although the -.B optparse -module was not a standard module until Python 2.3, -.B scons -contains a compatible version of the module -that is used to provide identical functionality -when run by earlier Python versions.) In addition to the arguments and values supported by the .B optparse.add_option () @@ -5500,7 +5490,7 @@ The default is to use a custom .B SCons.dblite module that uses pickled Python data structures, -and which works on all Python versions from 1.5.2 on. +and which works on all Python versions. Examples: diff --git a/doc/python10/process.xml b/doc/python10/process.xml index 6b049be..4ff0ab1 100644 --- a/doc/python10/process.xml +++ b/doc/python10/process.xml @@ -13,7 +13,7 @@ - &SCons; will be written to Python version 1.5.2 (to ensure + &SCons; will be written to Python version 2.4 (to ensure usability by a wide install base). diff --git a/doc/user/build-install.in b/doc/user/build-install.in index d6e4394..0d5d3c7 100644 --- a/doc/user/build-install.in +++ b/doc/user/build-install.in @@ -111,17 +111,6 @@ - (Note that the option - was added to Python version 2.0, - so if your system only has an earlier version available - you may see an - "Unknown option: -V" - error message.) - - - - - The standard location for information about downloading and installing Python is http://www.python.org/download/. @@ -132,10 +121,10 @@ - &SCons; will work with any version of Python from 1.5.2 or later. + &SCons; will work with any version of Python from 2.4 or later. If you need to install Python and have a choice, - we recommend using the most recent Python 2.5 version available. - Python 2.5 has significant improvements + we recommend using the most recent Python version available. + Newer Pythons have significant improvements that help speed up the performance of &SCons;. diff --git a/doc/user/build-install.xml b/doc/user/build-install.xml index d6e4394..0d5d3c7 100644 --- a/doc/user/build-install.xml +++ b/doc/user/build-install.xml @@ -111,17 +111,6 @@ - (Note that the option - was added to Python version 2.0, - so if your system only has an earlier version available - you may see an - "Unknown option: -V" - error message.) - - - - - The standard location for information about downloading and installing Python is http://www.python.org/download/. @@ -132,10 +121,10 @@ - &SCons; will work with any version of Python from 1.5.2 or later. + &SCons; will work with any version of Python from 2.4 or later. If you need to install Python and have a choice, - we recommend using the most recent Python 2.5 version available. - Python 2.5 has significant improvements + we recommend using the most recent Python version available. + Newer Pythons have significant improvements that help speed up the performance of &SCons;. diff --git a/doc/user/builders-built-in.in b/doc/user/builders-built-in.in index c7516a6..3b5b981 100644 --- a/doc/user/builders-built-in.in +++ b/doc/user/builders-built-in.in @@ -838,19 +838,6 @@ scons -Q . - - - If you're using Python version 1.5.2 to run &SCons;, - then &SCons; will try to use an external - &zip; program as follows: - - - - - % scons -Q . - zip /home/my/project/zip.out file1 file2 - - diff --git a/doc/user/builders-built-in.xml b/doc/user/builders-built-in.xml index 738683b..b5f3808 100644 --- a/doc/user/builders-built-in.xml +++ b/doc/user/builders-built-in.xml @@ -812,19 +812,6 @@ zip(["out.zip"], ["file1", "file2"]) - - - If you're using Python version 1.5.2 to run &SCons;, - then &SCons; will try to use an external - &zip; program as follows: - - - - - % scons -Q . - zip /home/my/project/zip.out file1 file2 - - diff --git a/doc/user/misc.in b/doc/user/misc.in index b087606..437d4fe 100644 --- a/doc/user/misc.in +++ b/doc/user/misc.in @@ -36,10 +36,10 @@ Although the &SCons; code itself will run - on any Python version 1.5.2 or later, + on any Python version 2.4 or later, you are perfectly free to make use of Python syntax and modules from more modern versions - (for example, Python 2.4 or 2.5) + (for example, Python 2.5 or 2.6) when writing your &SConscript; files or your own local modules. If you do this, it's usually helpful to diff --git a/doc/user/misc.xml b/doc/user/misc.xml index 7d2bf23..3cd3de7 100644 --- a/doc/user/misc.xml +++ b/doc/user/misc.xml @@ -36,10 +36,10 @@ Although the &SCons; code itself will run - on any Python version 1.5.2 or later, + on any Python version 2.4 or later, you are perfectly free to make use of Python syntax and modules from more modern versions - (for example, Python 2.4 or 2.5) + (for example, Python 2.5 or 2.6) when writing your &SConscript; files or your own local modules. If you do this, it's usually helpful to diff --git a/doc/user/tasks.in b/doc/user/tasks.in index 434871f..bf6b5ee 100644 --- a/doc/user/tasks.in +++ b/doc/user/tasks.in @@ -54,16 +54,6 @@ import os.path filenames = [os.path.join(prefix, x) for x in filenames] -or in Python 1.5.2: - - -import os.path -new_filenames = [] -for x in filenames: - new_filenames.append(os.path.join(prefix, x)) - - - Substituting a path prefix with another one @@ -71,14 +61,6 @@ if filename.find(old_prefix) == 0: filename = filename.replace(old_prefix, new_prefix) -or in Python 1.5.2: - - -if filename.find(old_prefix) == 0: - filename = filename.replace(old_prefix, new_prefix) - - - Filtering a filename list to exclude/retain only a specific set of extensions @@ -87,17 +69,6 @@ import os.path filenames = [x for x in filenames if os.path.splitext(x)[1] in extensions] -or in Python 1.5.2: - - -import os.path -new_filenames = [] -for x in filenames: - if os.path.splitext(x)[1] in extensions: - new_filenames.append(x) - - - The "backtick function": run a shell command and capture the output diff --git a/doc/user/tasks.xml b/doc/user/tasks.xml index 434871f..bf6b5ee 100644 --- a/doc/user/tasks.xml +++ b/doc/user/tasks.xml @@ -54,16 +54,6 @@ import os.path filenames = [os.path.join(prefix, x) for x in filenames] -or in Python 1.5.2: - - -import os.path -new_filenames = [] -for x in filenames: - new_filenames.append(os.path.join(prefix, x)) - - - Substituting a path prefix with another one @@ -71,14 +61,6 @@ if filename.find(old_prefix) == 0: filename = filename.replace(old_prefix, new_prefix) -or in Python 1.5.2: - - -if filename.find(old_prefix) == 0: - filename = filename.replace(old_prefix, new_prefix) - - - Filtering a filename list to exclude/retain only a specific set of extensions @@ -87,17 +69,6 @@ import os.path filenames = [x for x in filenames if os.path.splitext(x)[1] in extensions] -or in Python 1.5.2: - - -import os.path -new_filenames = [] -for x in filenames: - if os.path.splitext(x)[1] in extensions: - new_filenames.append(x) - - - The "backtick function": run a shell command and capture the output diff --git a/gentoo/scons.ebuild.in b/gentoo/scons.ebuild.in index 91e38a8..50c9ad9 100644 --- a/gentoo/scons.ebuild.in +++ b/gentoo/scons.ebuild.in @@ -12,7 +12,7 @@ SLOT="0" LICENSE="as-is" KEYWORDS="~x86 ~sparc" -DEPEND=">=dev-lang/python-2.0" +DEPEND=">=dev-lang/python-2.4" src_compile() { python setup.py build diff --git a/rpm/scons.spec.in b/rpm/scons.spec.in index f4564e4..4d2dd12 100644 --- a/rpm/scons.spec.in +++ b/rpm/scons.spec.in @@ -16,7 +16,7 @@ Prefix: %{_prefix} BuildArchitectures: noarch Vendor: Steven Knight Packager: Steven Knight -Requires: python >= 1.5 +Requires: python >= 2.4 Url: http://www.scons.org/ %description diff --git a/runtest.py b/runtest.py index e62ce92..eb2ec5e 100644 --- a/runtest.py +++ b/runtest.py @@ -85,8 +85,6 @@ # library directory. If we ever resurrect that as the default, then # you can find the appropriate code in the 0.04 version of this script, # rather than reinventing that wheel.) -# -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS import getopt import glob diff --git a/src/README.txt b/src/README.txt index f284327..7f9d330 100644 --- a/src/README.txt +++ b/src/README.txt @@ -30,7 +30,7 @@ the latest version by checking the SCons download page at: EXECUTION REQUIREMENTS ====================== -Running SCons requires Python version 1.5.2 or later. There should be +Running SCons requires Python version 2.4 or later. There should be no other dependencies or requirements to run SCons. (There is, however, an additional requirement to *install* SCons from this particular package; see the next section.) @@ -44,37 +44,7 @@ configuration of Environment construction variables. INSTALLATION REQUIREMENTS ========================= -Installing SCons from this package requires the Python distutils -package. The distutils package was not shipped as a standard part of -Python until Python version 1.6, so if your system is running Python -1.5.2, you may not have distutils installed. If you are running -Python version 1.6 or later, you should be fine. - -NOTE TO RED HAT USERS: Red Hat shipped Python 1.5.2 as the default all -the way up to Red Hat Linux 7.3, so you probably do *not* have distutils -installed, unless you have already done so manually or are running Red -Hat 8.0 or later. - -In this case, your options are: - - -- (Recommended.) Install from a pre-packaged SCons package that - does not require distutils: - - Red Hat Linux scons-__VERSION__-1.noarch.rpm - - Debian GNU/Linux scons___VERSION__-1_all.deb - (or use apt-get) - - Windows scons-__VERSION__.win32.exe - - -- (Optional.) Download the latest distutils package from the - following URL: - - http://www.python.org/sigs/distutils-sig/download.html - - Install the distutils according to the instructions on the page. - You can then proceed to the next section to install SCons from - this package. +Nothing special. INSTALLATION diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index e121752..bdfbb24 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -96,7 +96,6 @@ way for wrapping up the functions. # 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__" @@ -356,7 +355,6 @@ def _do_create_action(act, kw): return act if is_List(act): - #TODO(1.5) return CommandAction(act, **kw) return CommandAction(act, **kw) if callable(act): @@ -383,7 +381,6 @@ def _do_create_action(act, kw): return LazyAction(var, kw) commands = str(act).split('\n') if len(commands) == 1: - #TODO(1.5) return CommandAction(commands[0], **kw) return CommandAction(commands[0], **kw) # The list of string commands may include a LazyAction, so we # reprocess them via _do_create_list_action. @@ -687,7 +684,6 @@ class CommandAction(_ActionAction): # variables. if __debug__: logInstanceCreation(self, 'Action.CommandAction') - #TODO(1.5) _ActionAction.__init__(self, **kw) _ActionAction.__init__(self, **kw) if is_List(cmd): if list(filter(is_List, cmd)): @@ -862,7 +858,6 @@ class CommandGeneratorAction(ActionBase): source=source, env=env, for_signature=for_signature) - #TODO(1.5) gen_cmd = Action(ret, **self.gen_kw) gen_cmd = Action(ret, **self.gen_kw) if not gen_cmd: raise SCons.Errors.UserError("Object returned from command generator: %s cannot be used to create an Action." % repr(ret)) @@ -950,7 +945,6 @@ class LazyAction(CommandGeneratorAction, CommandAction): c = env.get(self.var, '') else: c = '' - #TODO(1.5) gen_cmd = Action(c, **self.gen_kw) gen_cmd = Action(c, **self.gen_kw) if not gen_cmd: raise SCons.Errors.UserError("$%s value %s cannot be used to create an Action." % (self.var, repr(c))) @@ -989,7 +983,6 @@ class FunctionAction(_ActionAction): # This is weird, just do the best we can. self.funccontents = _object_contents(execfunction) - #TODO(1.5) _ActionAction.__init__(self, **kw) _ActionAction.__init__(self, **kw) def function_name(self): @@ -1212,17 +1205,14 @@ class ActionCaller: def __call__(self, target, source, env, executor=None): args = self.subst_args(target, source, env) kw = self.subst_kw(target, source, env) - #TODO(1.5) return self.parent.actfunc(*args, **kw) return self.parent.actfunc(*args, **kw) def strfunction(self, target, source, env): args = self.subst_args(target, source, env) kw = self.subst_kw(target, source, env) - #TODO(1.5) return self.parent.strfunc(*args, **kw) return self.parent.strfunc(*args, **kw) def __str__(self): - #TODO(1.5) return self.parent.strfunc(*self.args, **self.kw) return self.parent.strfunc(*self.args, **self.kw) class ActionFactory: diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index f31d7da..529ce6e 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1506,9 +1506,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase): def f_global(target, source, env, for_signature): return SCons.Action.Action(GlobalFunc) - # TODO(1.5): - #def f_local(target, source, env, for_signature): - def f_local(target, source, env, for_signature, LocalFunc=LocalFunc): + def f_local(target, source, env, for_signature): return SCons.Action.Action(LocalFunc) env = Environment(XYZ = 'foo') @@ -1524,9 +1522,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase): def f_global(target, source, env, for_signature): return SCons.Action.Action(GlobalFunc, varlist=['XYZ']) - # TODO(1.5): - #def f_local(target, source, env, for_signature): - def f_local(target, source, env, for_signature, LocalFunc=LocalFunc): + def f_local(target, source, env, for_signature): return SCons.Action.Action(LocalFunc, varlist=['XYZ']) matches_foo = [x + "foo" for x in func_matches] diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 2e068c2..a9cbbd0 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -96,8 +96,6 @@ There are the following methods for internal use within this module: # 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/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index b1443bc..7ba4f8e 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -706,21 +706,10 @@ class BuilderTestCase(unittest.TestCase): tgt.build() assert env['CNT'][0] == 2 tgts = builder(env, None, infiles[2:4]) - try: - [].extend(collections.UserList()) - except TypeError: - # Old Python version (1.5.2) that can't handle extending - # a list with list-like objects. That means the return - # value from the builder call is a real list with Nodes, - # and doesn't have a __str__() method that stringifies - # the individual elements. Since we're gong to drop 1.5.2 - # support anyway, don't bother trying to test for it. - pass - else: - s = list(map(str, tgts)) - expect = [test.workpath('2.out'), test.workpath('3.out')] - expect = list(map(os.path.normcase, expect)) - assert list(map(os.path.normcase, s)) == expect, s + s = list(map(str, tgts)) + expect = [test.workpath('2.out'), test.workpath('3.out')] + expect = list(map(os.path.normcase, expect)) + assert list(map(os.path.normcase, s)) == expect, s for t in tgts: t.prepare() tgts[0].build() tgts[1].build() diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index 18e6546..85c0ec8 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -1,7 +1,6 @@ """SCons.Debug -Code for debugging SCons internal things. Not everything here is -guaranteed to work all the way back to Python 1.5.2, and shouldn't be +Code for debugging SCons internal things. Shouldn't be needed by most users. """ @@ -34,25 +33,17 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import sys import time - -# Recipe 14.10 from the Python Cookbook. -try: - import weakref -except ImportError: - def logInstanceCreation(instance, name=None): - pass -else: - def logInstanceCreation(instance, name=None): - if name is None: - name = instance.__class__.__name__ - if name not in tracked_classes: - tracked_classes[name] = [] - tracked_classes[name].append(weakref.ref(instance)) - - +import weakref tracked_classes = {} +def logInstanceCreation(instance, name=None): + if name is None: + name = instance.__class__.__name__ + if name not in tracked_classes: + tracked_classes[name] = [] + tracked_classes[name].append(weakref.ref(instance)) + def string_to_classes(s): if s == '*': return sorted(tracked_classes.keys()) @@ -93,6 +84,10 @@ if sys.platform[:5] == "linux": mstr = open('/proc/self/stat').read() mstr = mstr.split()[22] return int(mstr) +elif sys.platform[:6] == 'darwin': + #TODO really get memory stats for OS X + def memory(): + return 0 else: try: import resource diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 7dc20dc..f63854a 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -30,8 +30,6 @@ Environment # 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__" @@ -419,7 +417,7 @@ class SubstitutionEnvironment: # list works a little better in Python 2.5, but that has the # disadvantage of maybe getting out of sync if we ever add more # variable names. Using self._special_set.has_key() works a - # little better in Python 2.4, but is worse then this test. + # little better in Python 2.4, but is worse than this test. # So right now it seems like a good trade-off, but feel free to # revisit this with bench/env.__setitem__.py as needed (and # as newer versions of Python come out). @@ -586,7 +584,6 @@ class SubstitutionEnvironment: # othewise force a shell if not SCons.Util.is_List(command): kw['shell'] = True # run constructed command - #TODO(1.5) p = SCons.Action._subproc(self, command, **kw) p = SCons.Action._subproc(self, command, **kw) out,err = p.communicate() status = p.wait() @@ -663,15 +660,13 @@ class SubstitutionEnvironment: 'RPATH' : [], } - # The use of the "me" parameter to provide our own name for - # recursion is an egregious hack to support Python 2.1 and before. - def do_parse(arg, me, self = self, dict = dict): + def do_parse(arg): # if arg is a sequence, recurse with each element if not arg: return if not SCons.Util.is_String(arg): - for t in arg: me(t, me) + for t in arg: do_parse(t) return # if arg is a command, execute it @@ -790,7 +785,7 @@ class SubstitutionEnvironment: dict['CCFLAGS'].append(arg) for arg in flags: - do_parse(arg, do_parse) + do_parse(arg) return dict def MergeFlags(self, args, unique=1, dict=None): @@ -870,17 +865,6 @@ class SubstitutionEnvironment: # self.AppendENVPath(pathname, pathval) -# Used by the FindSourceFiles() method, below. -# Stuck here for support of pre-2.2 Python versions. -def build_source(ss, result): - for s in ss: - if isinstance(s, SCons.Node.FS.Dir): - build_source(s.all_children(), result) - elif s.has_builder(): - build_source(s.sources, result) - elif isinstance(s.disambiguate(), SCons.Node.FS.File): - result.append(s) - def default_decide_source(dependency, target, prev_ni): f = SCons.Defaults.DefaultEnvironment().decide_source return f(dependency, target, prev_ni) @@ -1498,11 +1482,9 @@ class Base(SubstitutionEnvironment): for line in lines: try: target, depends = line.split(':', 1) - except (AttributeError, TypeError, ValueError): - # Python 1.5.2 throws TypeError if line isn't a string, - # Python 2.x throws AttributeError because it tries - # to call line.split(). Either can throw ValueError - # if the line doesn't split into two or more elements. + except (AttributeError, ValueError): + # Throws AttributeError if line isn't a string. Can throw + # ValueError if line doesn't split into two or more elements. pass else: tdlist.append((target.split(), depends.split())) @@ -2140,17 +2122,15 @@ class Base(SubstitutionEnvironment): node = self.arg2nodes(node, self.fs.Entry)[0] sources = [] - # Uncomment this and get rid of the global definition when we - # drop support for pre-2.2 Python versions. - #def build_source(ss, result): - # for s in ss: - # if isinstance(s, SCons.Node.FS.Dir): - # build_source(s.all_children(), result) - # elif s.has_builder(): - # build_source(s.sources, result) - # elif isinstance(s.disambiguate(), SCons.Node.FS.File): - # result.append(s) - build_source(node.all_children(), sources) + def build_source(ss): + for s in ss: + if isinstance(s, SCons.Node.FS.Dir): + build_source(s.all_children()) + elif s.has_builder(): + build_source(s.sources) + elif isinstance(s.disambiguate(), SCons.Node.FS.File): + sources.append(s) + build_source(node.all_children()) # THIS CODE APPEARS TO HAVE NO EFFECT # # get the final srcnode for all nodes, this means stripping any diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index ddaa2ef..ce4e040 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -234,17 +234,9 @@ class SubstitutionTestCase(unittest.TestCase): def test_contains(self): """Test the SubstitutionEnvironment __contains__() method """ - try: - 'x' in {'x':1} - except TypeError: - # TODO(1.5) - # An early version of Python that doesn't support "in" - # on dictionaries. Just pass the test. - pass - else: - env = SubstitutionEnvironment(XXX = 'x') - assert 'XXX' in env - assert not 'YYY' in env + env = SubstitutionEnvironment(XXX = 'x') + assert 'XXX' in env + assert not 'YYY' in env def test_items(self): """Test the SubstitutionEnvironment items() method @@ -1706,17 +1698,8 @@ def exists(env): env['CLVar'] = CLVar([]) env.AppendUnique(CLVar = 'bar') result = env['CLVar'] - if sys.version[0] == '1' or sys.version[:3] == '2.0': - # Python 2.0 and before have a quirky behavior where CLVar([]) - # actually matches '' and [] due to different __coerce__() - # semantics in the UserList implementation. It isn't worth a - # lot of effort to get this corner case to work identically - # (support for Python 1.5 support will die soon anyway), - # so just treat it separately for now. - assert result == 'bar', result - else: - assert isinstance(result, CLVar), repr(result) - assert result == ['bar'], result + assert isinstance(result, CLVar), repr(result) + assert result == ['bar'], result env['CLVar'] = CLVar(['abc']) env.AppendUnique(CLVar = 'bar') @@ -2356,17 +2339,8 @@ f5: \ env['CLVar'] = CLVar([]) env.PrependUnique(CLVar = 'bar') result = env['CLVar'] - if sys.version[0] == '1' or sys.version[:3] == '2.0': - # Python 2.0 and before have a quirky behavior where CLVar([]) - # actually matches '' and [] due to different __coerce__() - # semantics in the UserList implementation. It isn't worth a - # lot of effort to get this corner case to work identically - # (support for Python 1.5 support will die soon anyway), - # so just treat it separately for now. - assert result == 'bar', result - else: - assert isinstance(result, CLVar), repr(result) - assert result == ['bar'], result + assert isinstance(result, CLVar), repr(result) + assert result == ['bar'], result env['CLVar'] = CLVar(['abc']) env.PrependUnique(CLVar = 'bar') @@ -3624,24 +3598,16 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture): def test_contains(self): """Test the OverrideEnvironment __contains__() method""" - try: - 'x' in {'x':1} - except TypeError: - # TODO(1.5) - # An early version of Python that doesn't support "in" - # on dictionaries. Just pass the test. - pass - else: - env, env2, env3 = self.envs - assert 'XXX' in env - assert 'XXX' in env2 - assert 'XXX' in env3 - assert 'YYY' in env - assert 'YYY' in env2 - assert 'YYY' in env3 - assert not 'ZZZ' in env - assert not 'ZZZ' in env2 - assert 'ZZZ' in env3 + env, env2, env3 = self.envs + assert 'XXX' in env + assert 'XXX' in env2 + assert 'XXX' in env3 + assert 'YYY' in env + assert 'YYY' in env2 + assert 'YYY' in env3 + assert not 'ZZZ' in env + assert not 'ZZZ' in env2 + assert 'ZZZ' in env3 def test_items(self): """Test the OverrideEnvironment Dictionary() method""" diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 813e08c..3b8c3f9 100644 --- a/src/engine/SCons/Errors.py +++ b/src/engine/SCons/Errors.py @@ -157,9 +157,7 @@ def convert_to_BuildError(status, exc_info=None): status=status, # might be 0, OK here exitstatus=status, # might be 0, OK here exc_info=exc_info) - # TODO(1.5): - #elif isinstance(status, (StopError, UserError)): - elif isinstance(status, StopError) or isinstance(status, UserError): + elif isinstance(status, (StopError, UserError)): buildError = BuildError( errstr=str(status), status=2, diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index feedf57..5dc1c39 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -26,8 +26,6 @@ Nodes. # 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__" @@ -237,16 +235,14 @@ class Executor: """Returns all targets for all batches of this Executor.""" result = [] for batch in self.batches: - # TODO(1.5): remove the list() cast - result.extend(list(batch.targets)) + result.extend(batch.targets) return result def get_all_sources(self): """Returns all sources for all batches of this Executor.""" result = [] for batch in self.batches: - # TODO(1.5): remove the list() cast - result.extend(list(batch.sources)) + result.extend(batch.sources) return result def get_all_children(self): @@ -271,8 +267,7 @@ class Executor: """ result = SCons.Util.UniqueList([]) for target in self.get_all_targets(): - # TODO(1.5): remove the list() cast - result.extend(list(target.prerequisites)) + result.extend(target.prerequisites) return result def get_action_side_effects(self): diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py index 08e37a5..879902f 100644 --- a/src/engine/SCons/Job.py +++ b/src/engine/SCons/Job.py @@ -295,9 +295,7 @@ else: worker = Worker(self.requestQueue, self.resultsQueue, interrupted) self.workers.append(worker) - # Once we drop Python 1.5 we can change the following to: - #if 'prev_size' in locals(): - if 'prev_size' in locals().keys(): + if 'prev_size' in locals(): threading.stack_size(prev_size) def put(self, task): diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py index 6e39d4b..4382e4a 100644 --- a/src/engine/SCons/JobTests.py +++ b/src/engine/SCons/JobTests.py @@ -19,8 +19,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/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 3175328..7bae6c1 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -31,8 +31,6 @@ that can be used by scripts or modules looking for the canonical default. # 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__" @@ -43,58 +41,7 @@ import shutil import stat import sys import time - -try: - import codecs -except ImportError: - pass -else: - # 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' - - # Provide a wrapper function to handle decoding differences in - # different versions of Python. Normally, we'd try to do this in the - # compat layer (and maybe it still makes sense to move there?) but - # that doesn't provide a way to supply the string class used in - # pre-2.3 Python versions with a .decode() method that all strings - # naturally have. Plus, the 2.[01] encodings behave differently - # enough that we have to settle for a lowest-common-denominator - # wrapper approach. - # - # Note that the 2.[012] implementations below may be inefficient - # because they perform an explicit look up of the encoding for every - # decode, but they're old enough (and we want to stop supporting - # them soon enough) that it's not worth complicating the interface. - # Think of it as additional incentive for people to upgrade... - 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() method 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) +import codecs import SCons.Action from SCons.Debug import logInstanceCreation @@ -2276,8 +2223,6 @@ class File(Base): def Dirs(self, pathlist): """Create a list of directories relative to the SConscript directory of this file.""" - # TODO(1.5) - # return [self.Dir(p) for p in pathlist] return [self.Dir(p) for p in pathlist] def File(self, name): @@ -2326,38 +2271,24 @@ class File(Base): raise return contents - try: - import codecs - except ImportError: - get_text_contents = get_contents - else: - # This attempts to figure out what the encoding of the text is - # based upon the BOM bytes, and then decodes the contents so that - # it's a valid python string. - def get_text_contents(self): - contents = self.get_contents() - # The behavior of various decode() methods and functions - # w.r.t. the initial BOM bytes is different for different - # encodings and/or Python versions. ('utf-8' does not strip - # them, but has a 'utf-8-sig' which does; 'utf-16' seems to - # strip them; etc.) Just side step all the complication by - # explicitly stripping the BOM before we decode(). - if contents.startswith(codecs.BOM_UTF8): - contents = contents[len(codecs.BOM_UTF8):] - # TODO(2.2): Remove when 2.3 becomes floor. - #contents = contents.decode('utf-8') - contents = my_decode(contents, 'utf-8') - elif contents.startswith(codecs.BOM_UTF16_LE): - contents = contents[len(codecs.BOM_UTF16_LE):] - # TODO(2.2): Remove when 2.3 becomes floor. - #contents = contents.decode('utf-16-le') - contents = my_decode(contents, '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 floor. - #contents = contents.decode('utf-16-be') - contents = my_decode(contents, 'utf-16-be') - return contents + # This attempts to figure out what the encoding of the text is + # based upon the BOM bytes, and then decodes the contents so that + # it's a valid python string. + def get_text_contents(self): + contents = self.get_contents() + # The behavior of various decode() methods and functions + # w.r.t. the initial BOM bytes is different for different + # encodings and/or Python versions. ('utf-8' does not strip + # them, but has a 'utf-8-sig' which does; 'utf-16' seems to + # strip them; etc.) Just sidestep all the complication by + # explicitly stripping the BOM before we decode(). + if contents.startswith(codecs.BOM_UTF8): + return contents[len(codecs.BOM_UTF8):].decode('utf-8') + if contents.startswith(codecs.BOM_UTF16_LE): + return contents[len(codecs.BOM_UTF16_LE):].decode('utf-16-le') + if contents.startswith(codecs.BOM_UTF16_BE): + return contents[len(codecs.BOM_UTF16_BE):].decode('utf-16-be') + return contents def get_content_hash(self): """ @@ -3140,7 +3071,7 @@ class FileFinder: # if isinstance(node, Dir) or isinstance(node, Entry): # return node # return None - #paths = filter(None, map(filedir_lookup, paths)) + #paths = [_f for _f in map(filedir_lookup, paths) if _f] self.default_filedir = filedir paths = [_f for _f in map(self.filedir_lookup, paths) if _f] diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 58726d3..7fcec8f 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1189,17 +1189,12 @@ class FSTestCase(_tempdirTestCase): f1 = fs.File(test.workpath("binary_file")) assert f1.get_contents() == "Foo\x1aBar", f1.get_contents() - try: - # TODO(1.5) - eval('test_string = u"Foo\x1aBar"') - except SyntaxError: - pass - else: - # This tests to make sure we can decode UTF-8 text files. - test.write("utf8_file", test_string.encode('utf-8')) - f1 = fs.File(test.workpath("utf8_file")) - assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \ - f1.get_text_contents() + # This tests to make sure we can decode UTF-8 text files. + test_string = u"Foo\x1aBar" + test.write("utf8_file", test_string.encode('utf-8')) + f1 = fs.File(test.workpath("utf8_file")) + assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \ + f1.get_text_contents() def nonexistent(method, s): try: @@ -1749,7 +1744,6 @@ class DirTestCase(_tempdirTestCase): e = self.fs.Dir(os.path.join('d', 'empty')) s = self.fs.Dir(os.path.join('d', 'sub')) - #TODO(1.5) files = d.get_contents().split('\n') files = d.get_contents().split('\n') assert e.get_contents() == '', e.get_contents() diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index beb9a31..db699d3 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -19,8 +19,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__" @@ -1280,15 +1278,8 @@ class NodeListTestCase(unittest.TestCase): l = [1] ul = collections.UserList([2]) - try: - l.extend(ul) - except TypeError: - # An older version of Python (*cough* 1.5.2 *cough*) - # that doesn't allow UserList objects to extend lists. - pass - else: - s = str(nl) - assert s == "['n3', 'n2', 'n1']", s + s = str(nl) + assert s == "['n3', 'n2', 'n1']", s r = repr(nl) r = re.sub('at (0[xX])?[0-9a-fA-F]+', 'at 0x', r) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 9a425b6..7847a9b 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -40,8 +40,6 @@ be able to depend on any other type of "thing." # 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__" @@ -1254,18 +1252,9 @@ class Node: lines = ["%s:\n" % preamble] + lines return ( ' '*11).join(lines) -try: - [].extend(collections.UserList([])) -except TypeError: - # Python 1.5.2 doesn't allow a list to be extended by list-like - # objects (such as UserList instances), so just punt and use - # real lists. - def NodeList(l): - return l -else: - class NodeList(collections.UserList): - def __str__(self): - return str(list(map(str, self.data))) +class NodeList(collections.UserList): + def __str__(self): + return str(list(map(str, self.data))) def get_children(node, parent): return node.children() def ignore_cycle(node, stack): pass diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 387312b..2d1cd61 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -155,9 +155,6 @@ def _stringSource( target, source, env ): return (str(target[0]) + ' <-\n |' + source[0].get_contents().replace( '\n', "\n |" ) ) -# python 2.2 introduces bool -BooleanTypes = [int, bool] - class SConfBuildInfo(SCons.Node.FS.FileBuildInfo): """ Special build info for targets of configure tests. Additional members @@ -783,7 +780,7 @@ class CheckContext: string. In case of an integer, the written text will be 'yes' or 'no'. The result is only displayed when self.did_show_result is not set. """ - if type(res) in BooleanTypes: + if isinstance(res, (int, bool)): if res: text = "yes" else: diff --git a/src/engine/SCons/Scanner/Dir.py b/src/engine/SCons/Scanner/Dir.py index f02904f..1cecfb7 100644 --- a/src/engine/SCons/Scanner/Dir.py +++ b/src/engine/SCons/Scanner/Dir.py @@ -19,8 +19,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/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index 74f44bc..29af9aa 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -25,8 +25,6 @@ This module implements the dependency scanner for Fortran code. # 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/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 904d612..9ea450b 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -57,12 +57,9 @@ def modify_env_var(env, var, abspath): env.PrependENVPath(var, abspath) try: if SCons.Util.is_List(env[var]): - #TODO(1.5) - #env.PrependENVPath(var, [os.path.abspath(str(p)) for p in env[var]]) env.PrependENVPath(var, [os.path.abspath(str(p)) for p in env[var]]) else: # Split at os.pathsep to convert into absolute path - #TODO(1.5) env.PrependENVPath(var, [os.path.abspath(p) for p in str(env[var]).split(os.pathsep)]) env.PrependENVPath(var, [os.path.abspath(p) for p in str(env[var]).split(os.pathsep)]) except KeyError: pass @@ -72,8 +69,6 @@ def modify_env_var(env, var, abspath): # does not work, refuses to append ":" (os.pathsep). if SCons.Util.is_List(env['ENV'][var]): - # TODO(1.5) - #env['ENV'][var] = os.pathsep.join(env['ENV'][var]) env['ENV'][var] = os.pathsep.join(env['ENV'][var]) # Append the trailing os.pathsep character here to catch the case with no env[var] env['ENV'][var] = env['ENV'][var] + os.pathsep @@ -251,10 +246,11 @@ class LaTeX(SCons.Scanner.Base): if include[0] == 'includegraphics': base, ext = os.path.splitext( filename ) if ext == "": - #TODO(1.5) return [filename + e for e in self.graphics_extensions] - #return map(lambda e: filename+e, self.graphics_extensions + TexGraphics) - # use the line above to find dependency for PDF builder when only .eps figure is present - # Since it will be found if the user tell scons how to make the pdf figure leave it out for now. + #return [filename+e for e in self.graphics_extensions + TexGraphics] + # use the line above to find dependencies for the PDF builder + # when only an .eps figure is present. Since it will be found + # if the user tells scons how to make the pdf figure, leave + # it out for now. return [filename+e for e in self.graphics_extensions] return [filename] @@ -335,19 +331,11 @@ class LaTeX(SCons.Scanner.Base): while queue: include = queue.pop() - # TODO(1.5): more compact: - #try: - # if seen[include[1]] == 1: - # continue - #except KeyError: - # seen[include[1]] = 1 try: - already_seen = seen[include[1]] + if seen[include[1]] == 1: + continue except KeyError: seen[include[1]] = 1 - already_seen = False - if already_seen: - continue # # Handle multiple filenames in include[1] diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index a356308..2e9a72a 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -19,8 +19,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__" @@ -571,14 +569,7 @@ class ClassicCPPTestCase(unittest.TestCase): assert n == 'path/bbb', n assert i == 'bbb', i - # TODO(1.5): remove when 2.2 is minimal; replace ccc - # variable in find_include() call below with in-line u'ccc'. - try: - ccc = eval("u'ccc'") - except SyntaxError: - ccc = 'ccc' - - n, i = s.find_include(('<', ccc), 'foo', ('path',)) + n, i = s.find_include(('<', u'ccc'), 'foo', ('path',)) assert n == 'path/ccc', n assert i == 'ccc', i diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index 63316fd..ffb5096 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -19,8 +19,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/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 7b58594..f78c2ec 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -32,8 +32,6 @@ it goes here. # 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__" @@ -270,13 +268,10 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): sys.stderr.write(errfmt % (nodename, buildError)) if (buildError.exc_info[2] and buildError.exc_info[1] and - # TODO(1.5) - #not isinstance( - # buildError.exc_info[1], - # (EnvironmentError, SCons.Errors.StopError, SCons.Errors.UserError))): - not isinstance(buildError.exc_info[1], EnvironmentError) and - not isinstance(buildError.exc_info[1], SCons.Errors.StopError) and - not isinstance(buildError.exc_info[1], SCons.Errors.UserError)): + not isinstance( + buildError.exc_info[1], + (EnvironmentError, SCons.Errors.StopError, + SCons.Errors.UserError))): type, value, trace = buildError.exc_info traceback.print_exception(type, value, trace) elif tb and print_stacktrace: diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 7f78a71..db52509 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -28,12 +28,7 @@ import re import sys import textwrap -try: - no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') -except re.error: - # Pre-2.0 Python versions don't have the (?<= negative - # look-behind assertion. - no_hyphen_re = re.compile(r'(\s+|-*\w{2,}-(?=\w{2,}))') +no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') try: from gettext import gettext diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 7640ec8..5928a88 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -26,8 +26,6 @@ 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 generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 465508c..bb7b632 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -64,9 +64,8 @@ if "--debug=memoizer" in _args: try: SCons.Memoize.EnableMemoization() except SCons.Warnings.Warning: - # Some warning was thrown (inability to --debug=memoizer on - # Python 1.5.2 because it doesn't have metaclasses). Arrange - # for it to be displayed or not after warnings are configured. + # Some warning was thrown. Arrange for it to be displayed + # or not after warnings are configured. import Main exc_type, exc_value, tb = sys.exc_info() Main.delayed_warnings.append((exc_type, exc_value)) diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index caddd75..be52772 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -25,8 +25,6 @@ SCons string substitution. # 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__" @@ -254,9 +252,6 @@ class Target_or_Source: class NullNodeList(SCons.Util.NullSeq): def __call__(self, *args, **kwargs): return '' def __str__(self): return '' - # TODO(1.5): unneeded after new-style classes introduce iterators - def __getitem__(self, i): - raise IndexError NullNodesList = NullNodeList() @@ -505,8 +500,8 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={ if is_String(args) and not isinstance(args, CmdStringHolder): args = str(args) # In case it's a UserString. try: - def sub_match(match, conv=self.conv, expand=self.expand, lvars=lvars): - return conv(expand(match.group(1), lvars)) + def sub_match(match): + return self.conv(self.expand(match.group(1), lvars)) result = _dollar_exps.sub(sub_match, args) except TypeError: # If the internal conversion routine doesn't return diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index 0334f14..fbd5037 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -533,9 +533,7 @@ class scons_subst_TestCase(SubstTestCase): scons_subst('$foo.bar.3.0', env) except SCons.Errors.UserError, e: expect = [ - # Python 1.5 - "SyntaxError `invalid syntax' trying to evaluate `$foo.bar.3.0'", - # Python 2.2, 2.3, 2.4 + # Python 2.3, 2.4 "SyntaxError `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'", # Python 2.5 "SyntaxError `invalid syntax (, line 1)' trying to evaluate `$foo.bar.3.0'", @@ -551,7 +549,7 @@ class scons_subst_TestCase(SubstTestCase): scons_subst("${NONE[2]}", env, gvars={'NONE':None}) except SCons.Errors.UserError, e: expect = [ - # Python 1.5, 2.2, 2.3, 2.4 + # Python 2.3, 2.4 "TypeError `unsubscriptable object' trying to evaluate `${NONE[2]}'", # Python 2.5 and later "TypeError `'NoneType' object is unsubscriptable' trying to evaluate `${NONE[2]}'", @@ -566,9 +564,7 @@ class scons_subst_TestCase(SubstTestCase): scons_subst("${func(1)}", env, gvars={'func':func}) except SCons.Errors.UserError, e: expect = [ - # Python 1.5 - "TypeError `not enough arguments; expected 3, got 1' trying to evaluate `${func(1)}'", - # Python 2.2, 2.3, 2.4, 2.5 + # Python 2.3, 2.4, 2.5 "TypeError `func() takes exactly 3 arguments (1 given)' trying to evaluate `${func(1)}'" ] assert str(e) in expect, repr(str(e)) diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index e55757a..0531f90 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -19,8 +19,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 __doc__ = """ Generic Taskmaster module for the SCons build engine. @@ -952,16 +950,7 @@ class Taskmaster: self.trace_node(n))) try: while True: - try: - node = to_visit.pop() - except AttributeError: - # Python 1.5.2 - if len(to_visit): - node = to_visit[0] - to_visit.remove(node) - else: - break - + node = to_visit.pop() node_func(node) # Prune recursion by flushing the waiting children @@ -981,7 +970,7 @@ class Taskmaster: pass # We have the stick back the pending_children list into the - # task master because the python 1.5.2 compatibility does not + # taskmaster because the python 1.5.2 compatibility does not # allow us to use in-place updates self.pending_children = pending_children @@ -998,16 +987,12 @@ class Taskmaster: if not self.pending_children: return - # TODO(1.5) - #nclist = [ (n, find_cycle([n], set())) for n in self.pending_children ] nclist = [(n, find_cycle([n], set())) for n in self.pending_children] - # TODO(1.5) - #genuine_cycles = [ - # node for node, cycle in nclist - # if cycle or node.get_state() != NODE_EXECUTED - #] - genuine_cycles = [t for t in nclist if t[1] or t[0].get_state() != NODE_EXECUTED] + genuine_cycles = [ + node for node,cycle in nclist + if cycle or node.get_state() != NODE_EXECUTED + ] if not genuine_cycles: # All of the "cycles" found were single nodes in EXECUTED state, # which is to say, they really weren't cycles. Just return. diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 3e9f62c..2353172 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -147,8 +147,6 @@ def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): # dkeep is a dict associating key: path_list, where key is one item from # keep, and pat_list the associated list of paths - # TODO(1.5): replace with the following list comprehension: - #dkeep = dict([(i, []) for i in keep]) dkeep = dict([(i, []) for i in keep]) # rdk will keep the regex to match the .bat file output line starts diff --git a/src/engine/SCons/Tool/MSCommon/netframework.py b/src/engine/SCons/Tool/MSCommon/netframework.py index c5f2880..6124e5b 100644 --- a/src/engine/SCons/Tool/MSCommon/netframework.py +++ b/src/engine/SCons/Tool/MSCommon/netframework.py @@ -19,8 +19,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/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py index 6994bc6..32bbc12 100644 --- a/src/engine/SCons/Tool/MSCommon/vs.py +++ b/src/engine/SCons/Tool/MSCommon/vs.py @@ -416,8 +416,6 @@ def get_default_version(env): the default version. """ if 'MSVS' not in env or not SCons.Util.is_Dict(env['MSVS']): - # TODO(1.5): - #versions = [vs.version for vs in get_installed_visual_studios()] versions = [vs.version for vs in get_installed_visual_studios()] env['MSVS'] = {'VERSIONS' : versions} else: @@ -473,8 +471,6 @@ def msvs_setup_env(env): vars = ('LIB', 'LIBPATH', 'PATH', 'INCLUDE') msvs_list = get_installed_visual_studios() - # TODO(1.5): - #vscommonvarnames = [ vs.common_tools_var for vs in msvs_list ] vscommonvarnames = [vs.common_tools_var for vs in msvs_list] nenv = normalize_env(env['ENV'], vscommonvarnames + ['COMSPEC']) output = get_output(batfilename, arch, env=nenv) @@ -487,8 +483,6 @@ def query_versions(): """Query the system to get available versions of VS. A version is considered when a batfile is found.""" msvs_list = get_installed_visual_studios() - # TODO(1.5) - #versions = [ msvs.version for msvs in msvs_list ] versions = [msvs.version for msvs in msvs_list] return versions diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index e068bf5..00d2b1b 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -34,8 +34,6 @@ tool definition. # 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/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index ef4d1ee..56e90ea 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -29,8 +29,6 @@ selection method. # 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/src/engine/SCons/Tool/ipkg.py b/src/engine/SCons/Tool/ipkg.py index 8e0940a..452cbb9 100644 --- a/src/engine/SCons/Tool/ipkg.py +++ b/src/engine/SCons/Tool/ipkg.py @@ -52,9 +52,6 @@ def generate(env): env['IPKG'] = 'ipkg-build' env['IPKGCOM'] = '$IPKG $IPKGFLAGS ${SOURCE}' - # TODO(1.5) - #env['IPKGUSER'] = os.popen('id -un').read().strip() - #env['IPKGGROUP'] = os.popen('id -gn').read().strip() env['IPKGUSER'] = os.popen('id -un').read().strip() env['IPKGGROUP'] = os.popen('id -gn').read().strip() env['IPKGFLAGS'] = SCons.Util.CLVar('-o $IPKGUSER -g $IPKGGROUP') diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index 6692a97..3ebd4bc 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -29,8 +29,6 @@ selection method. # 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/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index e932351..c8a6672 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,8 +29,6 @@ selection method. # 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__" @@ -389,8 +387,6 @@ class _GenerateV6DSP(_DSPGenerator): for base in ("BASE ",""): self.file.write('# PROP %sUse_MFC 0\n' '# PROP %sUse_Debug_Libraries ' % (base, base)) - # TODO(1.5): - #if kind.lower().find('debug') < 0: if kind.lower().find('debug') < 0: self.file.write('0\n') else: @@ -446,8 +442,6 @@ class _GenerateV6DSP(_DSPGenerator): continue # skip empty groups self.file.write('# Begin Group "' + kind + '"\n\n') - # TODO(1.5) - #typelist = categories[kind].replace('|', ';') typelist = categories[kind].replace('|', ';') self.file.write('# PROP Default_Filter "' + typelist + '"\n') @@ -471,8 +465,6 @@ class _GenerateV6DSP(_DSPGenerator): line = dspfile.readline() while line: - # TODO(1.5): - #if line.find("# End Project") > -1: if line.find("# End Project") > -1: break line = dspfile.readline() @@ -664,9 +656,6 @@ class _GenerateV7DSP(_DSPGenerator): rebuildcmd = xmlify(starting + self.env.subst('$MSVSREBUILDCOM', 1) + cmdargs) cleancmd = xmlify(starting + self.env.subst('$MSVSCLEANCOM', 1) + cmdargs) - # TODO(1.5) - #preprocdefs = xmlify(';'.join(self.env.get('CPPDEFINES', []))) - #includepath = xmlify(';'.join(self.env.get('CPPPATH', []))) preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) includepath = xmlify(';'.join(self.env.get('CPPPATH', []))) @@ -774,8 +763,6 @@ class _GenerateV7DSP(_DSPGenerator): line = dspfile.readline() while line: - # TODO(1.5) - #if line.find('