[llvm] Add text file support for z/OS back in (PR #209259)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 15:46:49 PDT 2026
================
@@ -65,18 +66,32 @@ 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)
- try:
- with open(path, "rb") as fileToCat:
- contents = fileToCat.read()
- except IOError as error:
- error.filename = filename
- stderr.write(str(error).encode())
- return 1
+
+ contents = None
+ is_text = False
+ if platform.system() == "OS/390":
+ try:
+ with open(path, "r") as fileToCat:
+ 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()
----------------
boomanaiden154 wrote:
It's unclear to me how this proposal would cause a semantic difference from what the code does now. When we set `is_text`, we're reading in text node, so `.read()` does not read an encoded form and we still only encode once.
https://github.com/llvm/llvm-project/pull/209259
More information about the llvm-commits
mailing list