From cd6edf4131d4c2b0f8752d13d902865bd2edb08d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 29 Mar 2026 11:23:56 -0700 Subject: [PATCH] CI: Catch UnicodeDecodeError in whitespace-check.py Changes behavior when a non-UTF-8 character is found from exiting the script with a Python exception traceback and no clue which file had it to reporting the filename and continuing to check the remaining files. Signed-off-by: Alan Coopersmith --- .gitlab-ci/whitespace-check.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/whitespace-check.py b/.gitlab-ci/whitespace-check.py index ca6745ab2..0c6db1430 100755 --- a/.gitlab-ci/whitespace-check.py +++ b/.gitlab-ci/whitespace-check.py @@ -94,7 +94,13 @@ def main(): reset = "" for file in args.files: - lines = [l.rstrip("\n") for l in file.open().readlines()] + try: + lines = [l.rstrip("\n") for l in file.open().readlines()] + except UnicodeDecodeError as e: + print(f"{red}ERROR: {e} in {file}:{reset}", file=sys.stderr) + print(f"{'-' * 72}", file=sys.stderr) + have_errors = True + continue errors = [] errors.extend(test_tab_indent(lines))