diff options
Diffstat (limited to 'src')
54 files changed, 259 insertions, 772 deletions
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__" |