python 3.9
TypeError: can't concat str to bytes
def PromoteUnstagedFiles(fileList):
if not fileList:
return
unstaged = RunProc("git", "diff-files", "--name-status", *fileList)
if unstaged:
sys.stdout.write("you have unstaged files, stage/discard them first.\n")
sys.stdout.write(unstaged + "\n")
sys.exit(1)
sys.stdout.write(unstaged + "\n")
TypeError: can't concat str to bytes
sys.stdout.write(unstaged.decode("utf-8") + b"\n")
sys.stdout.write(unstaged.decode("utf-8") + b"\n")
TypeError: can only concatenate str (not "bytes") to str
sys.stdout.write(unstaged + "\n")
改为
sys.stdout.write(unstaged.decode() + "\n")
bytes不能转换为字符串
unstaged 是 bytes,不是字符串
sys.stdout.write(str(b, unstaged= "utf-8") + "\n") 试试呢