Commits

Anonymous committed 59ed11a

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

Comments (0)

Files changed (6)

     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:

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"

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)

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)
 
 

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

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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.