[llvm] [llvm-lit] Resolve TypeError in built-in cat -v implementation (PR #98363)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 11:15:28 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: Connie (connieyzhu)

<details>
<summary>Changes</summary>

When using -v in lit's internal implementation of cat, there is a TypeError when the file data is passed into convertToCaretAndMNotation() as a str, because bytearray() requires an encoded string. This patch encodes the str before passing it through bytearray().

---
Full diff: https://github.com/llvm/llvm-project/pull/98363.diff


1 Files Affected:

- (modified) llvm/utils/lit/lit/builtin_commands/cat.py (+1-1) 


``````````diff
diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py
index 6fb2152ef9332..d6dbe889cc2b1 100644
--- a/llvm/utils/lit/lit/builtin_commands/cat.py
+++ b/llvm/utils/lit/lit/builtin_commands/cat.py
@@ -10,7 +10,7 @@
 def convertToCaretAndMNotation(data):
     newdata = StringIO()
     if isinstance(data, str):
-        data = bytearray(data)
+        data = bytearray(data.encode())
 
     for intval in data:
         if intval == 9 or intval == 10:

``````````

</details>


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


More information about the llvm-commits mailing list