[llvm] Add text file support for z/OS back in (PR #209259)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 10:57:33 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-testing-tools
Author: Sean Perry (perry-ca)
<details>
<summary>Changes</summary>
Support for auto conversion of text files was added to cat.py in https://github.com/llvm/llvm-project/pull/90128. That was accidently removed in https://github.com/llvm/llvm-project/pull/204711 while removing some old win32 code. This adds the z/OS support back in.
---
Full diff: https://github.com/llvm/llvm-project/pull/209259.diff
1 Files Affected:
- (modified) llvm/utils/lit/lit/builtin_commands/cat.py (+20-7)
``````````diff
diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py
index fc7d1229bc674..826cf94b1cb8e 100644
--- a/llvm/utils/lit/lit/builtin_commands/cat.py
+++ b/llvm/utils/lit/lit/builtin_commands/cat.py
@@ -65,18 +65,31 @@ def run(argv, stdin, stdout, stderr, cwd):
for filename in filenames:
path = filename
- contents = None
if not os.path.isabs(path):
path = os.path.join(cwd, path)
+
+ contents = None
+ is_text = False
try:
- with open(path, "rb") as fileToCat:
- contents = fileToCat.read()
- except IOError as error:
- error.filename = filename
- stderr.write(str(error).encode())
- return 1
+ fileToCat = open(filename, "r")
+ contents = fileToCat.read()
+ is_text = True
+ except:
+ pass
+
+ if contents is None:
+ try:
+ with open(path, "rb") as fileToCat:
+ contents = fileToCat.read()
+ except IOError as error:
+ error.filename = filename
+ stderr.write(str(error).encode())
+ return 1
+
if show_nonprinting:
contents = convertToCaretAndMNotation(contents)
+ elif is_text:
+ contents = contents.encode()
stdout.write(contents)
return 0
``````````
</details>
https://github.com/llvm/llvm-project/pull/209259
More information about the llvm-commits
mailing list