From e2ce959c903d1f2b1ff873ef57cfa1df1ebdcbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Fri, 3 Mar 2023 20:15:51 +0100 Subject: [PATCH] build.run: Handle UTF-8 encoding errors in SSH output gracefully MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, a toolchain might produce shell output that isn't correct UTF-8. To avoid crashing in such cases, pass errors="replace" to bytes.decode. For example, Lattice Diamond uses the Latin-1 encoding for some reason. This recently broke my setup because the month turned to "März" in a German locale: --- Start Time: Fr. M�r 3 20:01:41 2023 --- amaranth/build/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amaranth/build/run.py b/amaranth/build/run.py index b07da8e..c6a281d 100644 --- a/amaranth/build/run.py +++ b/amaranth/build/run.py @@ -176,7 +176,7 @@ class BuildPlan: # Show the output from the server while products are built. buf = channel.recv(1024) while buf: - print(buf.decode("utf-8"), end="") + print(buf.decode("utf-8", errors="replace"), end="") buf = channel.recv(1024) return RemoteSSHBuildProducts(connect_to, root)