python: Remove a call to reduce() from code_formatter.py.
authorGabe Black <gabeblack@google.com>
Tue, 13 Oct 2020 12:00:37 +0000 (05:00 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 14 Oct 2020 00:03:07 +0000 (00:03 +0000)
The built in reduce method is no longer available in python 3. Besides
that, this particular bit of code is simpler and easier to read if
reduce is replaced with the also built in sum() method.

Change-Id: I6daca42494ea0534721dfcfb1f6058517cd482d9
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35941
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/python/m5/util/code_formatter.py

index f441df0af507843a62b6098da6ccb0280dca4d60..37880de6507891c3938484c5fdb56b7ddcb7277d 100644 (file)
@@ -266,7 +266,7 @@ class code_formatter(object):
                 lineno = 1
             else:
                 lines = format[:i].splitlines(True)
-                colno = i - reduce(lambda x,y: x+y, (len(z) for z in lines))
+                colno = i - sum(len(z) for z in lines)
                 lineno = len(lines)
 
                 raise ValueError('Invalid format string: line %d, col %d' %