From 9d4291e590b304164598f32f63a8afbd6a2f2ec0 Mon Sep 17 00:00:00 2001
From: Paul Ferrell <51765748+Paul-Ferrell@users.noreply.github.com>
Date: Mon, 29 Nov 2021 05:27:02 -0700
Subject: Handle byte sequences which are not encoded as UTF8 while logging.
 (#21447)

Fix builds which produce a lines with non-UTF8 output while logging
The alternative is to read in binary mode, and then decode while
ignoring errors.
---
 lib/spack/llnl/util/tty/log.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'lib')

diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index efcd487f23..a7a4637ba9 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -780,7 +780,12 @@ def _writer_daemon(stdin_multiprocess_fd, read_multiprocess_fd, write_fd, echo,
                     try:
                         while line_count < 100:
                             # Handle output from the calling process.
-                            line = _retry(in_pipe.readline)()
+                            try:
+                                line = _retry(in_pipe.readline)()
+                            except UnicodeDecodeError:
+                                # installs like --test=root gpgme produce non-UTF8 logs
+                                line = '<line lost: output was not encoded as UTF-8>\n'
+
                             if not line:
                                 return
                             line_count += 1
-- 
cgit v1.2.3-70-g09d2