subprocess-tee errors when the subprocess prints a non- utf-8 character.
This is a difference between subprocess and subprocess-tee.
Reproduction
# my_script.sh
echo -e "\xC0\x80"
# reproducer.py
import subprocess
import subprocess_tee
print("Subprocess:")
subprocess.run(args=["bash", "my_script.sh"])
print("Subprocess tee:")
subprocess_tee.run(args=["bash", "my_script.sh"])
subprocess will replace invalid bytes with a placeholder character, while subprocess-tee errors with:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte
Fix
I suggest using errors="replace" on line.decode().
subprocess-teeerrors when the subprocess prints a non- utf-8 character.This is a difference between
subprocessandsubprocess-tee.Reproduction
subprocesswill replace invalid bytes with a placeholder character, whilesubprocess-teeerrors with:Fix
I suggest using
errors="replace"online.decode().