Fix a weird error when some time output files were causing bytes/str read errors.
diff --git a/litsupport/modules/timeit.py b/litsupport/modules/timeit.py
index 26b119d..8e364c2 100644
--- a/litsupport/modules/timeit.py
+++ b/litsupport/modules/timeit.py
@@ -94,7 +94,9 @@
def getUserTimeFromContents(contents):
- line = [line for line in contents.splitlines() if line.startswith('user')]
+ from_bytes = lambda s: s.decode("utf-8") if type(s) == bytes else s
+ lines = [from_bytes(l) for l in contents.splitlines()]
+ line = [line for line in lines if line.startswith('user')]
assert len(line) == 1
m = re.match(r'user\s+([0-9.]+)', line[0])