From 8a3e19c85c853ad7ee45b45e4afb63a617946145 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Tue, 20 Apr 2010 06:00:36 +0000 Subject: Rewrite uses of reduce(), which is being deprecated for Python 3.x. --- bench/bench.py | 4 +++- src/engine/SCons/Environment.py | 4 +++- src/engine/SCons/Node/FSTests.py | 5 ++++- src/engine/SCons/Node/NodeTests.py | 5 ++++- src/engine/SCons/Platform/__init__.py | 5 ++++- test/option/debug-time.py | 4 +++- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bench/bench.py b/bench/bench.py index 2acc29f..a839ed6 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -110,7 +110,9 @@ def timer(func, *args, **kw): return results def display(label, results): - total = reduce(lambda x, y: x+y, results, 0.0) + total = 0.0 + for r in results: + total += r print " %8.3f" % ((total * 1e6) / len(results)), ':', label for func in FunctionList: diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index cd637bb..d9db852 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -1507,7 +1507,9 @@ class Base(SubstitutionEnvironment): else: tdlist.append((target.split(), depends.split())) if only_one: - targets = reduce(lambda x, y: x+y, [p[0] for p in tdlist]) + targets = [] + for td in tdlist: + targets.extend(td[0]) if len(targets) > 1: raise SCons.Errors.UserError( "More than one dependency target found in `%s': %s" diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 339d124..58726d3 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -2093,7 +2093,10 @@ class EntryTestCase(_tempdirTestCase): def __init__(self, val): self.val = val def collect(self, args): - return reduce(lambda x, y: x+y, args) + result = 0 + for a in args: + result += a + return result def signature(self, executor): return self.val + 222 self.module = M(val) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 6de6d38..beb9a31 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -215,7 +215,10 @@ class Calculator: def signature(self, args): return self.val def collect(self, args): - return reduce(lambda x, y: x+y, args, self.val) + result = self.val + for a in args: + result += a + return result self.module = M(val) diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 244d090..e1066f0 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -166,7 +166,10 @@ class TempFileMunge: except ValueError: maxline = 2048 - if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline: + length = 0 + for c in cmd: + length += len(c) + if length <= maxline: return self.cmd # We do a normpath because mktemp() has what appears to be diff --git a/test/option/debug-time.py b/test/option/debug-time.py index a1e0254..39a47c1 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -110,7 +110,9 @@ expected_total_time = complete_time - overhead pattern = r'Command execution time: (\d+\.\d+) seconds' times = list(map(float, re.findall(pattern, test.stdout()))) -expected_command_time = reduce(lambda x, y: x + y, times, 0.0) +expected_command_time = 0.0 +for t in times: + expected_command_time += t stdout = test.stdout() -- cgit v0.12