Commits

Steven Knight  committed 59ed11a

Rewrite uses of reduce(), which is being deprecated for Python 3.x.

  • Participants
  • Parent commits 91b9312

Comments (0)

Files changed (6)

File bench/bench.py

     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:

File src/engine/SCons/Environment.py

             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"

File src/engine/SCons/Node/FSTests.py

                     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)

File src/engine/SCons/Node/NodeTests.py

             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)
 
 

File src/engine/SCons/Platform/__init__.py

         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

File test/option/debug-time.py

 
 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()