TypeError: can't concat str to bytes

问题遇到的现象和发生背景

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")

img

bytes不能转换为字符串
unstaged 是 bytes,不是字符串
sys.stdout.write(str(b, unstaged= "utf-8") + "\n") 试试呢