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

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 15:55:02 PDT 2024


Author: Connie
Date: 2024-07-18T15:54:58-07:00
New Revision: ef94732b4fa0512a3a635766b872c1574a1aade4

URL: https://github.com/llvm/llvm-project/commit/ef94732b4fa0512a3a635766b872c1574a1aade4
DIFF: https://github.com/llvm/llvm-project/commit/ef94732b4fa0512a3a635766b872c1574a1aade4.diff

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

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().

Added: 
    

Modified: 
    llvm/utils/lit/lit/builtin_commands/cat.py

Removed: 
    


################################################################################
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:


        


More information about the llvm-commits mailing list