From cf7e0e3fefb69504ee623904c2914721e6dd7c61 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 30 Jan 2026 00:43:35 -0600 Subject: [PATCH] scripts: csv.py: Tweaked foldchecking to check that folds match I mean, what would you expect this to do? max(a) + sum(b) Whatever your answer is, it's wrong (the way csv.py works, we always compute folds after expr evaluation). The best option is to error, matching the behavior of mismatched types. --- scripts/csv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/csv.py b/scripts/csv.py index 0cb04ae2..95d36e5f 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -538,7 +538,10 @@ class CsvExpr: return t def fold(self, types={}): - return self.a.fold(types) + f = self.a.fold(types) + if not all(f == v.fold(types) for v in it.islice(self, 1, None)): + raise CsvExpr.Error("mismatched folds? %r" % self) + return f def eval(self, fields={}, state=None): return self.a.eval(fields, state)