diff options
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 <knight at baldmt dot com>" __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 <knight at baldmt dot com>" __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] @@ -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++ @@ -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 <<EOF\ns/^#zlib/zlib/\nw\nq\nEOF\n' - cmd.run((edit_modules_setup_in,), display) - cmd.run('./configure --prefix=%(prefix)s %(configureflags)s 2>&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 <moshez@debian.org> -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 @@ <listitem> <para> - &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). </para> 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 @@ <para> - (Note that the <option>-V</option> option - was added to Python version 2.0, - so if your system only has an earlier version available - you may see an - <literal>"Unknown option: -V"</literal> - error message.) - - </para> - - <para> - The standard location for information about downloading and installing Python is <ulink url="http://www.python.org/download/">http://www.python.org/download/</ulink>. @@ -132,10 +121,10 @@ <para> - &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;. </para> 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 @@ <para> - (Note that the <option>-V</option> option - was added to Python version 2.0, - so if your system only has an earlier version available - you may see an - <literal>"Unknown option: -V"</literal> - error message.) - - </para> - - <para> - The standard location for information about downloading and installing Python is <ulink url="http://www.python.org/download/">http://www.python.org/download/</ulink>. @@ -132,10 +121,10 @@ <para> - &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;. </para> 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_output_command>scons -Q .</scons_output_command> </scons_output> - <para> - - If you're using Python version 1.5.2 to run &SCons;, - then &SCons; will try to use an external - &zip; program as follows: - - </para> - - <screen> - % <userinput>scons -Q .</userinput> - zip /home/my/project/zip.out file1 file2 - </screen> - </section> </section> 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"]) </screen> - <para> - - If you're using Python version 1.5.2 to run &SCons;, - then &SCons; will try to use an external - &zip; program as follows: - - </para> - - <screen> - % <userinput>scons -Q .</userinput> - zip /home/my/project/zip.out file1 file2 - </screen> - </section> </section> 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 @@ <para> 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 @@ <para> 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] </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -import os.path -new_filenames = [] -for x in filenames: - new_filenames.append(os.path.join(prefix, x)) -</programlisting> -</example> - <example> <title>Substituting a path prefix with another one</title> <programlisting> @@ -71,14 +61,6 @@ if filename.find(old_prefix) == 0: filename = filename.replace(old_prefix, new_prefix) </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -if filename.find(old_prefix) == 0: - filename = filename.replace(old_prefix, new_prefix) -</programlisting> -</example> - <example> <title>Filtering a filename list to exclude/retain only a specific set of extensions</title> @@ -87,17 +69,6 @@ import os.path filenames = [x for x in filenames if os.path.splitext(x)[1] in extensions] </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -import os.path -new_filenames = [] -for x in filenames: - if os.path.splitext(x)[1] in extensions: - new_filenames.append(x) -</programlisting> -</example> - <example> <title>The "backtick function": run a shell command and capture the output</title> 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] </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -import os.path -new_filenames = [] -for x in filenames: - new_filenames.append(os.path.join(prefix, x)) -</programlisting> -</example> - <example> <title>Substituting a path prefix with another one</title> <programlisting> @@ -71,14 +61,6 @@ if filename.find(old_prefix) == 0: filename = filename.replace(old_prefix, new_prefix) </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -if filename.find(old_prefix) == 0: - filename = filename.replace(old_prefix, new_prefix) -</programlisting> -</example> - <example> <title>Filtering a filename list to exclude/retain only a specific set of extensions</title> @@ -87,17 +69,6 @@ import os.path filenames = [x for x in filenames if os.path.splitext(x)[1] in extensions] </programlisting> -<simpara>or in Python 1.5.2:</simpara> - -<programlisting> -import os.path -new_filenames = [] -for x in filenames: - if os.path.splitext(x)[1] in extensions: - new_filenames.append(x) -</programlisting> -</example> - <example> <title>The "backtick function": run a shell command and capture the output</title> 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 <knight@scons.org> Packager: Steven Knight <knight@scons.org> -Requires: python >= 1.5 +Requires: python >= 2.4 Url: http://www.scons.org/ %description @@ -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 (<string>, 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('<!-- SCons Data:') > -1: if line.find('<!-- SCons Data:') > -1: break line = dspfile.readline() diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py index 462228f..95311a2 100644 --- a/src/engine/SCons/Tool/packaging/__init__.py +++ b/src/engine/SCons/Tool/packaging/__init__.py @@ -24,8 +24,6 @@ SCons Packaging Tool. # 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/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py index 95adbed..fe78c9c 100644 --- a/src/engine/SCons/Tool/packaging/msi.py +++ b/src/engine/SCons/Tool/packaging/msi.py @@ -24,8 +24,6 @@ The msi packager. # 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/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index d5c1c71..2372ed9 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -24,8 +24,6 @@ The rpm packager. # 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/tex.py b/src/engine/SCons/Tool/tex.py index 3a84d21..a2870b5 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -236,8 +236,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None # # routine to update MD5 hash and compare # - # TODO(1.5): nested scopes - def check_MD5(filenode, suffix, saved_hashes=saved_hashes, targetbase=targetbase): + def check_MD5(filenode, suffix): global must_rerun_latex # two calls to clear old csig filenode.clear_memoized_values() @@ -427,8 +426,6 @@ def is_LaTeX(flist,env,abspath): pass else: # Split at os.pathsep to convert into absolute path - # TODO(1.5) - #paths = paths.split(os.pathsep) paths = paths.split(os.pathsep) # now that we have the path list restore the env @@ -653,8 +650,6 @@ def tex_emitter_core(target, source, env, graphics_extensions): pass else: # Split at os.pathsep to convert into absolute path - # TODO(1.5) - #paths = paths.split(os.pathsep) paths = paths.split(os.pathsep) # now that we have the path list restore the env diff --git a/src/engine/SCons/Tool/zip.xml b/src/engine/SCons/Tool/zip.xml index c7c233e..87b8de0 100644 --- a/src/engine/SCons/Tool/zip.xml +++ b/src/engine/SCons/Tool/zip.xml @@ -90,10 +90,9 @@ is compressed or not. The default value is <literal>zipfile.ZIP_DEFLATED</literal>, which creates a compressed zip archive. -This value has no effect when using Python 1.5.2 -or if the +This value has no effect if the <literal>zipfile</literal> -module is otherwise unavailable. +module is unavailable. </summary> </cvar> diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d11d779..299d9e1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -304,272 +304,137 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited={}): # exception, but handling the exception when it's not the right type is # often too slow. -try: - class mystr(str): - pass -except TypeError: - # An older Python version without new-style classes. - # - # The actual implementations here have been selected after timings - # coded up in in bench/is_types.py (from the SCons source tree, - # see the scons-src distribution), mostly against Python 1.5.2. - # Key results from those timings: - # - # -- Storing the type of the object in a variable (t = type(obj)) - # slows down the case where it's a native type and the first - # comparison will match, but nicely speeds up the case where - # it's a different native type. Since that's going to be - # common, it's a good tradeoff. - # - # -- The data show that calling isinstance() on an object that's - # a native type (dict, list or string) is expensive enough - # that checking up front for whether the object is of type - # InstanceType is a pretty big win, even though it does slow - # down the case where it really *is* an object instance a - # little bit. - def is_Dict(obj): - t = type(obj) - return t is DictType or \ - (t is InstanceType and isinstance(obj, UserDict)) - - def is_List(obj): - t = type(obj) - return t is ListType \ - or (t is InstanceType and isinstance(obj, UserList)) - - def is_Sequence(obj): - t = type(obj) - return t is ListType \ - or t is TupleType \ - or (t is InstanceType and isinstance(obj, UserList)) - - def is_Tuple(obj): - t = type(obj) - return t is TupleType - - if UnicodeType is not None: - def is_String(obj): - t = type(obj) - return t is StringType \ - or t is UnicodeType \ - or (t is InstanceType and isinstance(obj, UserString)) - else: - def is_String(obj): - t = type(obj) - return t is StringType \ - or (t is InstanceType and isinstance(obj, UserString)) - - def is_Scalar(obj): - return is_String(obj) or not is_Sequence(obj) - - def flatten(obj, result=None): - """Flatten a sequence to a non-nested list. - - Flatten() converts either a single scalar or a nested sequence - to a non-nested list. Note that flatten() considers strings - to be scalars instead of sequences like Python would. - """ - if is_Scalar(obj): - return [obj] - if result is None: - result = [] - for item in obj: - if is_Scalar(item): - result.append(item) - else: - flatten_sequence(item, result) - return result - - def flatten_sequence(sequence, result=None): - """Flatten a sequence to a non-nested list. - - Same as flatten(), but it does not handle the single scalar - case. This is slightly more efficient when one knows that - the sequence to flatten can not be a scalar. - """ - if result is None: - result = [] - for item in sequence: - if is_Scalar(item): - result.append(item) - else: - flatten_sequence(item, result) - return result - - # - # Generic convert-to-string functions that abstract away whether or - # not the Python we're executing has Unicode support. The wrapper - # to_String_for_signature() will use a for_signature() method if the - # specified object has one. - # - if UnicodeType is not None: - def to_String(s): - if isinstance(s, UserString): - t = type(s.data) - else: - t = type(s) - if t is UnicodeType: - return unicode(s) - else: - return str(s) - else: - to_String = str - - def to_String_for_signature(obj): - try: - f = obj.for_signature - except AttributeError: - return to_String_for_subst(obj) +# We are using the following trick to speed up these +# functions. Default arguments are used to take a snapshot of the +# the global functions and constants used by these functions. This +# transforms accesses to global variable into local variables +# accesses (i.e. LOAD_FAST instead of LOAD_GLOBAL). + +DictTypes = (dict, UserDict) +ListTypes = (list, UserList) +SequenceTypes = (list, tuple, UserList) + +# Note that profiling data shows a speed-up when comparing +# explicitely with str and unicode instead of simply comparing +# with basestring. (at least on Python 2.5.1) +StringTypes = (str, unicode, UserString) + +# Empirically, it is faster to check explicitely for str and +# unicode than for basestring. +BaseStringTypes = (str, unicode) + +def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): + return isinstance(obj, DictTypes) + +def is_List(obj, isinstance=isinstance, ListTypes=ListTypes): + return isinstance(obj, ListTypes) + +def is_Sequence(obj, isinstance=isinstance, SequenceTypes=SequenceTypes): + return isinstance(obj, SequenceTypes) + +def is_Tuple(obj, isinstance=isinstance, tuple=tuple): + return isinstance(obj, tuple) + +def is_String(obj, isinstance=isinstance, StringTypes=StringTypes): + return isinstance(obj, StringTypes) + +def is_Scalar(obj, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes): + # Profiling shows that there is an impressive speed-up of 2x + # when explicitely checking for strings instead of just not + # sequence when the argument (i.e. obj) is already a string. + # But, if obj is a not string then it is twice as fast to + # check only for 'not sequence'. The following code therefore + # assumes that the obj argument is a string must of the time. + return isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes) + +def do_flatten(sequence, result, isinstance=isinstance, + StringTypes=StringTypes, SequenceTypes=SequenceTypes): + for item in sequence: + if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): + result.append(item) else: - return f() + do_flatten(item, result) - def to_String_for_subst(s): - if is_Sequence( s ): - return ' '.join( map(to_String_for_subst, s) ) +def flatten(obj, isinstance=isinstance, StringTypes=StringTypes, + SequenceTypes=SequenceTypes, do_flatten=do_flatten): + """Flatten a sequence to a non-nested list. - return to_String( s ) - -else: - # A modern Python version with new-style classes, so we can just use - # isinstance(). - # - # We are using the following trick to speed-up these - # functions. Default arguments are used to take a snapshot of the - # the global functions and constants used by these functions. This - # transforms accesses to global variable into local variables - # accesses (i.e. LOAD_FAST instead of LOAD_GLOBAL). - - DictTypes = (dict, UserDict) - ListTypes = (list, UserList) - SequenceTypes = (list, tuple, UserList) - - # Empirically, Python versions with new-style classes all have - # unicode. - # - # Note that profiling data shows a speed-up when comparing - # explicitely with str and unicode instead of simply comparing - # with basestring. (at least on Python 2.5.1) - StringTypes = (str, unicode, UserString) - - # Empirically, it is faster to check explicitely for str and - # unicode than for basestring. - BaseStringTypes = (str, unicode) - - def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): - return isinstance(obj, DictTypes) - - def is_List(obj, isinstance=isinstance, ListTypes=ListTypes): - return isinstance(obj, ListTypes) - - def is_Sequence(obj, isinstance=isinstance, SequenceTypes=SequenceTypes): - return isinstance(obj, SequenceTypes) - - def is_Tuple(obj, isinstance=isinstance, tuple=tuple): - return isinstance(obj, tuple) - - def is_String(obj, isinstance=isinstance, StringTypes=StringTypes): - return isinstance(obj, StringTypes) - - def is_Scalar(obj, isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes): - # Profiling shows that there is an impressive speed-up of 2x - # when explicitely checking for strings instead of just not - # sequence when the argument (i.e. obj) is already a string. - # But, if obj is a not string then it is twice as fast to - # check only for 'not sequence'. The following code therefore - # assumes that the obj argument is a string must of the time. - return isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes) - - def do_flatten(sequence, result, isinstance=isinstance, - StringTypes=StringTypes, SequenceTypes=SequenceTypes): - for item in sequence: - if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): - result.append(item) - else: - do_flatten(item, result) - - def flatten(obj, isinstance=isinstance, StringTypes=StringTypes, - SequenceTypes=SequenceTypes, do_flatten=do_flatten): - """Flatten a sequence to a non-nested list. - - Flatten() converts either a single scalar or a nested sequence - to a non-nested list. Note that flatten() considers strings - to be scalars instead of sequences like Python would. - """ - if isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes): - return [obj] - result = [] - for item in obj: - if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): - result.append(item) - else: - do_flatten(item, result) - return result - - def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, - SequenceTypes=SequenceTypes, do_flatten=do_flatten): - """Flatten a sequence to a non-nested list. - - Same as flatten(), but it does not handle the single scalar - case. This is slightly more efficient when one knows that - the sequence to flatten can not be a scalar. - """ - result = [] - for item in sequence: - if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): - result.append(item) - else: - do_flatten(item, result) - return result + Flatten() converts either a single scalar or a nested sequence + to a non-nested list. Note that flatten() considers strings + to be scalars instead of sequences like Python would. + """ + if isinstance(obj, StringTypes) or not isinstance(obj, SequenceTypes): + return [obj] + result = [] + for item in obj: + if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): + result.append(item) + else: + do_flatten(item, result) + return result +def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, + SequenceTypes=SequenceTypes, do_flatten=do_flatten): + """Flatten a sequence to a non-nested list. - # - # Generic convert-to-string functions that abstract away whether or - # not the Python we're executing has Unicode support. The wrapper - # to_String_for_signature() will use a for_signature() method if the - # specified object has one. - # - def to_String(s, - isinstance=isinstance, str=str, - UserString=UserString, BaseStringTypes=BaseStringTypes): - if isinstance(s,BaseStringTypes): - # Early out when already a string! - return s - elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. - return s.data - else: - return str(s) - - def to_String_for_subst(s, - isinstance=isinstance, str=str, to_String=to_String, - BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, - UserString=UserString): - - # Note that the test cases are sorted by order of probability. - if isinstance(s, BaseStringTypes): - return s - elif isinstance(s, SequenceTypes): - l = [] - for e in s: - l.append(to_String_for_subst(e)) - return ' '.join( s ) - elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. - return s.data + Same as flatten(), but it does not handle the single scalar + case. This is slightly more efficient when one knows that + the sequence to flatten can not be a scalar. + """ + result = [] + for item in sequence: + if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): + result.append(item) else: - return str(s) + do_flatten(item, result) + return result - def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, - AttributeError=AttributeError): - try: - f = obj.for_signature - except AttributeError: - return to_String_for_subst(obj) - else: - return f() +# Generic convert-to-string functions that abstract away whether or +# not the Python we're executing has Unicode support. The wrapper +# to_String_for_signature() will use a for_signature() method if the +# specified object has one. +# +def to_String(s, + isinstance=isinstance, str=str, + UserString=UserString, BaseStringTypes=BaseStringTypes): + if isinstance(s,BaseStringTypes): + # Early out when already a string! + return s + elif isinstance(s, UserString): + # s.data can only be either a unicode or a regular + # string. Please see the UserString initializer. + return s.data + else: + return str(s) + +def to_String_for_subst(s, + isinstance=isinstance, str=str, to_String=to_String, + BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, + UserString=UserString): + + # Note that the test cases are sorted by order of probability. + if isinstance(s, BaseStringTypes): + return s + elif isinstance(s, SequenceTypes): + l = [] + for e in s: + l.append(to_String_for_subst(e)) + return ' '.join( s ) + elif isinstance(s, UserString): + # s.data can only be either a unicode or a regular + # string. Please see the UserString initializer. + return s.data + else: + return str(s) +def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, + AttributeError=AttributeError): + try: + f = obj.for_signature + except AttributeError: + return to_String_for_subst(obj) + else: + return f() # The SCons "semi-deep" copy. @@ -1505,17 +1370,10 @@ def RenameFunction(function, name): Returns a function identical to the specified function, but with the specified name. """ - # Compatibility for Python 1.5 and 2.1. Can be removed in favor of - # passing function.func_defaults directly to new.function() once - # we base on Python 2.2 or later. - func_defaults = function.func_defaults - if func_defaults is None: - func_defaults = () - return types.FunctionType(function.func_code, function.func_globals, name, - func_defaults) + function.func_defaults) md5 = False @@ -1584,8 +1442,7 @@ def silent_intern(x): # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 # ASPN: Python Cookbook: Null Object Design Pattern -# TODO(1.5): -#class Null(object): +#TODO??? class Null(object): class Null: """ Null objects always and reliably "do nothing." """ def __new__(cls, *args, **kwargs): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 15ee2a6..a4d69d7 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -700,7 +700,7 @@ bling def test_intern(self): s1 = silent_intern("spam") - # Python 1.5 and 3.x do not have a unicode() built-in + # Python 3.x does not have a unicode() global function if sys.version[0] == '2': s2 = silent_intern(unicode("unicode spam")) s3 = silent_intern(42) diff --git a/src/engine/SCons/Variables/ListVariable.py b/src/engine/SCons/Variables/ListVariable.py index 6cab091..413aacb 100644 --- a/src/engine/SCons/Variables/ListVariable.py +++ b/src/engine/SCons/Variables/ListVariable.py @@ -45,8 +45,6 @@ Usage example: # 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/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py index 750d4b3..41f5dd1 100644 --- a/src/engine/SCons/Variables/__init__.py +++ b/src/engine/SCons/Variables/__init__.py @@ -25,8 +25,6 @@ customizable variables to an SCons build. # 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__" @@ -84,11 +82,11 @@ class Variables: # if we get a list or a tuple, we take the first element as the # option key and store the remaining in aliases. if SCons.Util.is_List(key) or SCons.Util.is_Tuple(key): - option.key = key[0] - option.aliases = key[1:] + option.key = key[0] + option.aliases = key[1:] else: - option.key = key - option.aliases = [ key ] + option.key = key + option.aliases = [ key ] option.help = help option.default = default option.validator = validator @@ -99,10 +97,8 @@ class Variables: # options might be added after the 'unknown' dict has been set up, # so we remove the key and all its aliases from that dict for alias in list(option.aliases) + [ option.key ]: - # TODO(1.5) - #if alias in self.unknown: - if alias in self.unknown.keys(): - del self.unknown[alias] + if alias in self.unknown: + del self.unknown[alias] def keys(self): """ @@ -128,8 +124,8 @@ class Variables: return if not SCons.Util.is_String(key) or \ - not SCons.Environment.is_valid_construction_var(key): - raise SCons.Errors.UserError("Illegal Variables.Add() key `%s'" % str(key)) + not SCons.Environment.is_valid_construction_var(key): + raise SCons.Errors.UserError("Illegal Variables.Add() key `%s'" % str(key)) self._do_add(key, help, default, validator, converter) diff --git a/src/engine/SCons/compat/_scons_hashlib.py b/src/engine/SCons/compat/_scons_hashlib.py index 102304a7..15cb9e3 100644 --- a/src/engine/SCons/compat/_scons_hashlib.py +++ b/src/engine/SCons/compat/_scons_hashlib.py @@ -61,23 +61,8 @@ class md5obj: def update(self, arg): return self.m.update(arg) - if hasattr(md5.md5(), 'hexdigest'): - - def hexdigest(self): - return self.m.hexdigest() - - else: - - # Objects created by the underlying md5 module have no native - # hexdigest() method (*cough* 1.5.2 *cough*), so provide an - # equivalent lifted from elsewhere. - def hexdigest(self): - h = hexdigits - r = '' - for c in self.digest(): - i = ord(c) - r = r + h[(i >> 4) & 0xF] + h[i & 0xF] - return r + def hexdigest(self): + return self.m.hexdigest() new = md5obj diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 9442942..f8eec89 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -26,11 +26,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __doc__ = """ SCons C Pre-Processor module """ - -# TODO(1.5): remove this import -# This module doesn't use anything from SCons by name, but we import SCons -# here to pull in zip() from the SCons.compat layer for early Pythons. -import SCons +#TODO 2.3 and before has no sorted() +import SCons.compat import os import re @@ -191,9 +188,7 @@ class FunctionEvaluator: self.args = function_arg_separator.split(args) try: expansion = expansion.split('##') - except (AttributeError, TypeError): - # Python 1.5 throws TypeError if "expansion" isn't a string, - # later versions throw AttributeError. + except AttributeError: pass self.expansion = expansion def __call__(self, *values): diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 6586a0f..b35cc32 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -31,7 +31,6 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # from __future__ import nested_scopes -from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/script/sconsign.py b/src/script/sconsign.py index cfba945..759c5ad 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -22,8 +22,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/setup.py b/src/setup.py index 0dbb012..3c91757 100644 --- a/src/setup.py +++ b/src/setup.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/test_aegistests.py b/src/test_aegistests.py index 744f141..67b0e3f 100644 --- a/src/test_aegistests.py +++ b/src/test_aegistests.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/src/test_interrupts.py b/src/test_interrupts.py index 21b0dea..fb12e2a 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.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/src/test_pychecker.py b/src/test_pychecker.py index fdcc7d7..f87d303 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.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/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', |