replace malformed data if there are encoding errors

This commit is contained in:
Bence Pőcze 2023-10-26 13:40:02 +02:00
parent dde8c1dd9e
commit b8f095e1a9

View File

@ -3,7 +3,12 @@ from typing import Iterator
def subprocess_readlines(cmd, cwd=None) -> Iterator[str]:
process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, text=True)
process = subprocess.Popen(cmd,
cwd=cwd,
stdout=subprocess.PIPE,
text=True,
encoding='utf-8',
errors='replace')
for line in process.stdout:
line = line.rstrip('\n')