[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().
diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py
index 6fb2152..d6dbe88 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: