mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-09-21 21:03:38 +08:00
fix: harden subprocess output decoding across lessons
This commit is contained in:
@@ -89,7 +89,7 @@ def run_bash(command: str) -> str:
|
||||
return "Error: Dangerous command blocked"
|
||||
try:
|
||||
r = subprocess.run(command, shell=True, cwd=WORKDIR,
|
||||
capture_output=True, text=True, timeout=120)
|
||||
capture_output=True, text=True, errors="replace", timeout=120)
|
||||
out = (r.stdout + r.stderr).strip()
|
||||
return out[:50000] if out else "(no output)"
|
||||
except subprocess.TimeoutExpired:
|
||||
@@ -345,7 +345,7 @@ class BackgroundManager:
|
||||
def _exec(self, tid: str, command: str, timeout: int):
|
||||
try:
|
||||
r = subprocess.run(command, shell=True, cwd=WORKDIR,
|
||||
capture_output=True, text=True, timeout=timeout)
|
||||
capture_output=True, text=True, errors="replace", timeout=timeout)
|
||||
output = (r.stdout + r.stderr).strip()[:50000]
|
||||
self.tasks[tid].update({"status": "completed", "result": output or "(no output)"})
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user