fix: repair sweep fallout — duplicate encoding kwargs, non-subprocess call sites, kwarg-snapshot tests
- Strip the salvaged commit's inline encoding kwargs where main had since gained its own (process_registry, local env, cua doctor, gateway, commands, gateway_windows — the latter keeps its locale-aware _schtasks_encoding() from #38186) - Revert encoding kwargs mistakenly applied to non-subprocess APIs (exa get_contents, tempfile.mkstemp in webhook.py) - Guard the ddgs worker Popen (new on main since #55339) - Update two kwarg-snapshot test assertions for the new kwargs
This commit is contained in:
@@ -1669,7 +1669,7 @@ class SlashCommandCompleter(Completer):
|
||||
continue
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
cmd, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=2,
|
||||
cmd, capture_output=True, text=True, timeout=2,
|
||||
cwd=cwd, encoding="utf-8", errors="replace",
|
||||
)
|
||||
if proc.returncode == 0 and proc.stdout and proc.stdout.strip():
|
||||
|
||||
@@ -421,7 +421,7 @@ def _scan_gateway_pids(
|
||||
"/FORMAT:LIST",
|
||||
],
|
||||
capture_output=True,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="ignore",
|
||||
timeout=10,
|
||||
@@ -447,7 +447,7 @@ def _scan_gateway_pids(
|
||||
result = subprocess.run(
|
||||
[powershell, "-NoProfile", "-Command", ps_cmd],
|
||||
capture_output=True,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="ignore",
|
||||
timeout=15,
|
||||
|
||||
@@ -160,7 +160,7 @@ def _exec_schtasks(args: list[str]) -> tuple[int, str, str]:
|
||||
proc = subprocess.run(
|
||||
[schtasks, *args],
|
||||
capture_output=True,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
# Localized Windows emits schtasks output in the console code page,
|
||||
# not UTF-8. Decode with the locale encoding and replace undecodable
|
||||
# bytes so a non-UTF-8 status line never surfaces a UnicodeDecodeError
|
||||
|
||||
@@ -59,7 +59,7 @@ def _save_subscriptions(subs: Dict[str, dict]) -> None:
|
||||
prefix=f".{path.name}.",
|
||||
suffix=".tmp",
|
||||
dir=path.parent,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
)
|
||||
tmp_path = Path(tmp_name)
|
||||
try:
|
||||
|
||||
@@ -193,6 +193,8 @@ def _run_ddgs_search_bounded(query: str, safe_limit: int) -> list[dict[str, Any]
|
||||
stderr=subprocess.DEVNULL,
|
||||
env=env,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
**extra_kwargs,
|
||||
)
|
||||
_last_worker_proc = proc
|
||||
|
||||
@@ -170,7 +170,7 @@ class ExaWebSearchProvider(WebSearchProvider):
|
||||
]
|
||||
|
||||
logger.info("Exa extract: %d URL(s)", len(urls))
|
||||
response = _get_exa_client().get_contents(urls, text=True, encoding='utf-8', errors='replace')
|
||||
response = _get_exa_client().get_contents(urls, text=True)
|
||||
|
||||
results: List[Dict[str, Any]] = []
|
||||
for result in response.results or []:
|
||||
|
||||
@@ -206,9 +206,10 @@ def test_restore_stashed_changes_keeps_going_when_stash_entry_cannot_be_resolved
|
||||
restored = hermes_main._restore_stashed_changes(["git"], tmp_path, "abc123", prompt_user=False)
|
||||
|
||||
assert restored is True
|
||||
assert calls[0] == (["git", "stash", "apply", "abc123"], {"cwd": tmp_path, "capture_output": True, "text": True})
|
||||
assert calls[1] == (["git", "diff", "--name-only", "--diff-filter=U"], {"cwd": tmp_path, "capture_output": True, "text": True})
|
||||
assert calls[2] == (["git", "stash", "list", "--format=%gd %H"], {"cwd": tmp_path, "capture_output": True, "text": True, "check": True})
|
||||
_utf8 = {"encoding": "utf-8", "errors": "replace"}
|
||||
assert calls[0] == (["git", "stash", "apply", "abc123"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8})
|
||||
assert calls[1] == (["git", "diff", "--name-only", "--diff-filter=U"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8})
|
||||
assert calls[2] == (["git", "stash", "list", "--format=%gd %H"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8, "check": True})
|
||||
out = capsys.readouterr().out
|
||||
assert "couldn't find the stash entry to drop" in out
|
||||
assert "stash was left in place" in out
|
||||
|
||||
@@ -116,6 +116,8 @@ def test_ensure_docker_available_uses_resolved_executable(monkeypatch):
|
||||
(["/opt/homebrew/bin/docker", "version"], {
|
||||
"capture_output": True,
|
||||
"text": True,
|
||||
"encoding": "utf-8",
|
||||
"errors": "replace",
|
||||
"timeout": 5,
|
||||
"stdin": subprocess.DEVNULL,
|
||||
})
|
||||
|
||||
@@ -99,7 +99,7 @@ def _drive_health_report(
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
bufsize=1,
|
||||
|
||||
@@ -1403,7 +1403,7 @@ class LocalEnvironment(BaseEnvironment):
|
||||
|
||||
proc = subprocess.Popen(
|
||||
args,
|
||||
text=True, encoding='utf-8', errors='replace',
|
||||
text=True,
|
||||
env=run_env,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
|
||||
Reference in New Issue
Block a user