[llvm] [lit] Use text mode when piping output (PR #217434)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 12:01:41 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r origin/main...HEAD llvm/utils/lit/lit/ShellEnvironment.py llvm/utils/lit/lit/TestRunner.py llvm/utils/lit/lit/builtin_commands/cat.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- TestRunner.py	2026-08-19 18:55:57.000000 +0000
+++ TestRunner.py	2026-08-19 19:01:09.842082 +0000
@@ -401,11 +401,11 @@
         A SpooledTemporaryFile, which stays in memory unless its size or
         a downstream call to .fileno() forces it to disk. None for the
         last stage or a non-pipe target, which don't need this sink.
     """
     if stdout == subprocess.PIPE and not is_last:
-        return tempfile.SpooledTemporaryFile(max_size=1 << 20, mode='w+')
+        return tempfile.SpooledTemporaryFile(max_size=1 << 20, mode="w+")
     return None
 
 
 def _resolve_err_sink(stderr: int | TextIO, merge_err: bool) -> ByteWriter | None:
     """Wraps a '2>file' redirect target as a binary writer.
--- builtin_commands/cat.py	2026-08-19 18:55:57.000000 +0000
+++ builtin_commands/cat.py	2026-08-19 19:01:09.919581 +0000
@@ -90,13 +90,13 @@
 
         if show_nonprinting:
             contents = convertToCaretAndMNotation(contents)
         # Determine if stdout expects text or binary
         is_text_output = False
-        if hasattr(stdout, 'mode'):
-            mode = getattr(stdout, 'mode', 'b')
-            is_text_output = 'b' not in mode
+        if hasattr(stdout, "mode"):
+            mode = getattr(stdout, "mode", "b")
+            is_text_output = "b" not in mode
 
         if is_text_output:
             if isinstance(contents, bytes):
                 contents = contents.decode()
             stdout.write(contents)

``````````

</details>


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


More information about the llvm-commits mailing list