[llvm] [lit] Use text mode when opening text files on z/OS (PR #217434)

Abhina Sree via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 06:08:39 PDT 2026


================
@@ -63,11 +64,22 @@ def getDirTree(path, basedir=""):
 def compareTwoFiles(flags, filepaths, stdin, stdout):
     filelines = []
     for file in filepaths:
+        is_text = False
         if file == "-":
             filelines.append(stdin.readlines())
         else:
-            with open(file, "rb") as file_bin:
-                filelines.append(file_bin.readlines())
+            if platform.system() == "OS/390":
+                try:
+                    with open(file, "r") as file_text:
+                        filelines.append(
+                            file_text.read().encode().splitlines(keepends=True)
+                        )
+                        is_text = True
+                except:
+                    pass
----------------
abhina-sree wrote:

I copied this structure from the existing cat.py. We first try to read it as text, and if it fails, we fall through to reading it as binary

https://github.com/llvm/llvm-project/pull/217434


More information about the llvm-commits mailing list