mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
fix(run_command): decode subprocess output as UTF-8 on Windows
GBK default decoding failed on curl/wttr.in UTF-8 output, leaving stdout empty with exit 0; use utf-8 + replace. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
95dfa7020a
commit
75a3038f33
1 changed files with 4 additions and 0 deletions
|
|
@ -108,11 +108,15 @@ class LocalAdapter:
|
||||||
# It only uses explicit cwd; otherwise defaults to data/workspace.
|
# It only uses explicit cwd; otherwise defaults to data/workspace.
|
||||||
workdir = str(resolve_workspace_path(cwd or "data/workspace"))
|
workdir = str(resolve_workspace_path(cwd or "data/workspace"))
|
||||||
Path(workdir).mkdir(parents=True, exist_ok=True)
|
Path(workdir).mkdir(parents=True, exist_ok=True)
|
||||||
|
# Use UTF-8 for decoded streams: Windows defaults (e.g. GBK) break on UTF-8-only bytes from
|
||||||
|
# curl/wttr.in, git, ripgrep, etc.; subprocess may leave stdout None after UnicodeDecodeError.
|
||||||
run_kwargs: dict[str, Any] = {
|
run_kwargs: dict[str, Any] = {
|
||||||
"cwd": workdir,
|
"cwd": workdir,
|
||||||
"shell": True,
|
"shell": True,
|
||||||
"capture_output": True,
|
"capture_output": True,
|
||||||
"text": True,
|
"text": True,
|
||||||
|
"encoding": "utf-8",
|
||||||
|
"errors": "replace",
|
||||||
"timeout": float(timeout_s),
|
"timeout": float(timeout_s),
|
||||||
}
|
}
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue