Commit 7459ae8d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

patches/python: use math.fsum for the sum of numeric values.

parent 0e2ea035
Pipeline #35287 failed with stage
in 0 seconds
...@@ -174,3 +174,17 @@ def patch_linecache(): ...@@ -174,3 +174,17 @@ def patch_linecache():
linecache.getlines = getlines linecache.getlines = getlines
patch_linecache() patch_linecache()
orig_sum = __builtins__['sum']
from math import fsum
def sum_(iterable, start=0):
if start == 0:
ret = fsum(iterable)
int_ret = int(ret)
if int_ret == ret:
return int_ret
else:
return ret
else:
return orig_sum(iterable, start)
__builtins__['sum'] = sum_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment