未验证 提交 dfaea348 编写于 作者: F Frost Ming

fix: replace unicode errors with replacement chars

Close #1319
上级 888ec0b5
Fix the build failure when the subprocess outputs with non-UTF8 characters.
......@@ -40,7 +40,6 @@ class LoggerWrapper(threading.Thread):
# create the pipe and reader
self.fd_read, self.fd_write = os.pipe()
self.reader = os.fdopen(self.fd_read, encoding="utf-8")
self.start()
......@@ -52,11 +51,9 @@ class LoggerWrapper(threading.Thread):
return msg[:-1] if msg.endswith("\n") else msg
def run(self) -> None:
try:
for line in self.reader:
with os.fdopen(self.fd_read, encoding="utf-8", errors="replace") as reader:
for line in reader:
self._write(self.remove_newline(line))
finally:
self.reader.close()
def _write(self, message: str) -> None:
self.logger.log(self.level, message)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册