replace malformed data if there are encoding errors

This commit is contained in:
bence committed 2023-10-26 13:41:02 +02:00
1 parent dde8c1dd9e
commit b8f095e1a9
1 file changed
+6 -1
+6 -1
View File
@@ -3,7 +3,12 @@ from typing import Iterator
def subprocess_readlines(cmd, cwd=None) -> Iterator[str]: 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: for line in process.stdout:
line = line.rstrip('\n') line = line.rstrip('\n')