fix: harden subprocess output decoding across lessons

This commit is contained in:
Haoran
2026-08-26 01:05:16 +08:00
parent 3e17b98504
commit cce031e632
34 changed files with 178 additions and 75 deletions

View File

@@ -454,7 +454,7 @@ def _run_git(args: list[str], cwd: Path | None = None) -> tuple[bool, str]:
try:
result = subprocess.run(
["git", *args], cwd=cwd or WORKDIR,
capture_output=True, text=True, timeout=30,
capture_output=True, text=True, errors="replace", timeout=30,
)
except (OSError, subprocess.TimeoutExpired) as exc:
return False, f"{type(exc).__name__}: {exc}"
@@ -903,7 +903,7 @@ def _run_bash_process(command: str, cwd: Path | None = None) -> tuple[str, int |
process = subprocess.Popen(
command, shell=True, cwd=cwd or WORKDIR,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
text=True, start_new_session=True,
text=True, errors="replace", start_new_session=True,
)
with _shell_process_lock:
_shell_processes.add(process)