[flang-commits] [flang] [Flang][Windows] Fix test_errors.py by enforcing UTF-8 encoding (PR #134625)
Omair Javaid via flang-commits
flang-commits at lists.llvm.org
Mon Apr 7 06:24:50 PDT 2025
https://github.com/omjavaid created https://github.com/llvm/llvm-project/pull/134625
This patch fixes UnicodeDecodeError on Windows in test_errors.py. This issue was observed on the flang-arm64-windows-msvc buildbot. Semantics/OpenMP/interop-construct.f90 was crashing due to Python defaulting to the cp1252 codec on Windows.
I have fixed this by explicitly setting encoding="utf-8" when reading source files and invoking subprocess.run() in test_errors.py
flang-arm64-windows-msvc was running on stagging master which resulted in this issue not being fixed earlier.
https://lab.llvm.org/staging/#/builders/206
>From 79fc87c5db872b20baaa0c051ea49d7464b5db49 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid <omair.javaid at linaro.org>
Date: Mon, 7 Apr 2025 18:08:45 +0500
Subject: [PATCH] [Flang][Windows] Fix test_errors.py by enforcing UTF-8
encoding
This patch fixes UnicodeDecodeError on Windows in test_errors.py.
This issue was observed on the flang-arm64-windows-msvc buildbot.
Semantics/OpenMP/interop-construct.f90 was crashing due to Python
defaulting to the cp1252 codec on Windows
I have fixed this by explicitly setting encoding="utf-8" when reading
source files and invoking subprocess.run() in test_errors.py
flang-arm64-windows-msvc was running on stagging master which resulted
in this issue not being fixed earlier.
https://lab.llvm.org/staging/#/builders/206
---
flang/test/Semantics/test_errors.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/flang/test/Semantics/test_errors.py b/flang/test/Semantics/test_errors.py
index 63ff3367edefd..45684764a00e4 100755
--- a/flang/test/Semantics/test_errors.py
+++ b/flang/test/Semantics/test_errors.py
@@ -17,7 +17,7 @@
cm.check_args(sys.argv)
srcdir = cm.set_source(sys.argv[1])
-with open(srcdir, "r") as f:
+with open(srcdir, "r", encoding="utf-8") as f:
src = f.readlines()
actual = ""
expect = ""
@@ -39,6 +39,7 @@
check=True,
universal_newlines=True,
cwd=tmpdir,
+ encoding="utf-8",
)
except subprocess.CalledProcessError as e:
log = e.stderr
More information about the flang-commits
mailing list