From 484b7dd1e8f02820481fad5d227efcb4670b54e1 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 2 Feb 2026 12:15:00 -0600 Subject: [PATCH] scripts: csv.py: Ignore missing by fields in enumerate/accumulate Note this matches the behavior of mods, e.g. I would expect this to not break if ORDER is missing: ./scripts/csv.py \ -bcase='%(case)s+%(probe)s+%(ORDER)s' \ -ft=accumulate(bench_simtime, case, probe, ORDER) Normally the expr compiler would force typechecking of ORDER, giving it a default value of int(0) if missing, but we intentionally bypass typechecking in enumerate/accumulate's by fields since they may be strings. --- scripts/csv.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/csv.py b/scripts/csv.py index 5b4ce95c..a078cc79 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -812,12 +812,8 @@ class CsvExpr: return CsvInt(0) # enumerate - k = ['enumerate', id(self)] - for v in self: - if v.a not in fields: - raise CsvExpr.Error("unknown field? %s" % v.a) - k.append(fields[v.a]) - k = tuple(k) + k = ('enumerate', id(self)) + tuple( + fields.get(v.a) for v in self) x = state.get(k) if x is None: x = 0 @@ -852,12 +848,8 @@ class CsvExpr: return y # accumulate - k = ['accumulate', id(self)] - for v in it.islice(self, 1, None): - if v.a not in fields: - raise CsvExpr.Error("unknown field? %s" % v.a) - k.append(fields[v.a]) - k = tuple(k) + k = ('accumulate', id(self)) + tuple( + fields.get(v.a) for v in it.islice(self, 1, None)) x = state.get(k) if x is None: x = y