Skip to content

Commit 5c6e875

Browse files
fix: add UTF-8 encoding for subprocess calls on Windows
On Windows, subprocess.Popen/run with text=True defaults to CP1252 encoding instead of UTF-8. This causes UnicodeDecodeError when Claude outputs characters outside the CP1252 codepage. Add explicit encoding="utf-8" and errors="replace" parameters to all subprocess calls that use text=True. Files modified: - parallel_orchestrator.py (3 locations) - start.py (2 locations) - start_ui.py (1 location) Closes #138 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 79d02a1 commit 5c6e875

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

parallel_orchestrator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,14 @@ def _spawn_coding_agent(self, feature_id: int) -> tuple[bool, str]:
511511
try:
512512
# CREATE_NO_WINDOW on Windows prevents console window pop-ups
513513
# stdin=DEVNULL prevents blocking on stdin reads
514+
# encoding="utf-8" and errors="replace" fix Windows CP1252 issues (#138)
514515
popen_kwargs = {
515516
"stdin": subprocess.DEVNULL,
516517
"stdout": subprocess.PIPE,
517518
"stderr": subprocess.STDOUT,
518519
"text": True,
520+
"encoding": "utf-8",
521+
"errors": "replace",
519522
"cwd": str(AUTOCODER_ROOT), # Run from autocoder root for proper imports
520523
"env": {**os.environ, "PYTHONUNBUFFERED": "1"},
521524
}
@@ -600,11 +603,14 @@ def _spawn_testing_agent(self) -> tuple[bool, str]:
600603
try:
601604
# CREATE_NO_WINDOW on Windows prevents console window pop-ups
602605
# stdin=DEVNULL prevents blocking on stdin reads
606+
# encoding="utf-8" and errors="replace" fix Windows CP1252 issues (#138)
603607
popen_kwargs = {
604608
"stdin": subprocess.DEVNULL,
605609
"stdout": subprocess.PIPE,
606610
"stderr": subprocess.STDOUT,
607611
"text": True,
612+
"encoding": "utf-8",
613+
"errors": "replace",
608614
"cwd": str(AUTOCODER_ROOT),
609615
"env": {**os.environ, "PYTHONUNBUFFERED": "1"},
610616
}
@@ -658,11 +664,14 @@ async def _run_initializer(self) -> bool:
658664

659665
# CREATE_NO_WINDOW on Windows prevents console window pop-ups
660666
# stdin=DEVNULL prevents blocking on stdin reads
667+
# encoding="utf-8" and errors="replace" fix Windows CP1252 issues (#138)
661668
popen_kwargs = {
662669
"stdin": subprocess.DEVNULL,
663670
"stdout": subprocess.PIPE,
664671
"stderr": subprocess.STDOUT,
665672
"text": True,
673+
"encoding": "utf-8",
674+
"errors": "replace",
666675
"cwd": str(AUTOCODER_ROOT),
667676
"env": {**os.environ, "PYTHONUNBUFFERED": "1"},
668677
}

start.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def run_spec_creation(project_dir: Path) -> bool:
231231
check=False, # Don't raise on non-zero exit
232232
cwd=str(Path(__file__).parent), # Run from project root
233233
stderr=subprocess.PIPE,
234-
text=True
234+
text=True,
235+
encoding="utf-8", # Fix Windows CP1252 encoding issue (#138)
236+
errors="replace",
235237
)
236238

237239
# Check for authentication errors in stderr
@@ -400,7 +402,9 @@ def run_agent(project_name: str, project_dir: Path) -> None:
400402
cmd,
401403
check=False,
402404
stderr=subprocess.PIPE,
403-
text=True
405+
text=True,
406+
encoding="utf-8", # Fix Windows CP1252 encoding issue (#138)
407+
errors="replace",
404408
)
405409

406410
# Check for authentication errors

start_ui.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ def check_node() -> bool:
127127
result = subprocess.run(
128128
["node", "--version"],
129129
capture_output=True,
130-
text=True
130+
text=True,
131+
encoding="utf-8", # Fix Windows CP1252 encoding issue (#138)
132+
errors="replace",
131133
)
132134
print(f" Node.js version: {result.stdout.strip()}")
133135
except Exception:

0 commit comments

Comments
 (0)