Skip to contentSkip to conversation

scripts/lib/buildstats: handle top-level build_stats not being complete

PATCH New Ross Burton 1 participant 1 message Mar 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/lib/buildstats: handle top-level build_stats not being complete

If we try to parse a buildstats directory which was either aborted or is still being built then the top-level build_stats file doesn't contain an elapsed value which causes an exception:

UnboundLocalError: local variable 'elapsed' referenced before assignment

Default both start and elapsed to 0 so that the parse succeeds.

---
 scripts/lib/buildstats.py | 1 +
 1 file changed, 1 insertion(+)
scripts/lib/buildstats.py +1 -0
index c9a238bb127..9f8c9061505 100644
@@ -239,6 +239,7 @@ class BuildStats(dict):
         """
         Parse the top-level build_stats file for build-wide start and duration.
         """
+        start = elapsed = 0
         with open(path) as fobj:
             for line in fobj.readlines():
                 key, val = line.split(':', 1)
Signature · 1 line
2.34.1