Skip to content

fix: add encoding='utf-8', errors='replace' to subprocess.Popen - #14553

Closed
shushuzn wants to merge 1 commit into
NousResearch:mainfrom
shushuzn:fix/browser-encoding-clean
Closed

shushuzn wants to merge 1 commit into
NousResearch:mainfrom
shushuzn:fix/browser-encoding-clean

Conversation

@shushuzn

Copy link
Copy Markdown
Contributor

Fix: Windows GBK encoding error in browser tool

Problem: On Windows, subprocess.Popen defaults to system encoding (GBK).
When reading browser command output from GitHub pages (UTF-8 content), Python
fails with:

'gbk' codec can't decode byte 0xa6 in position 1068: illegal multibyte sequence

Solution: Add encoding='utf-8', errors='replace' as kwargs to
subprocess.Popen in _run_browser_command.

Files changed: Only tools/browser_tool.py — adds two lines:

proc = subprocess.Popen(
    ...,
    encoding='utf-8',   # NEW
    errors='replace',  # NEW
)

Testing: Verified on Windows — browser_navigate + browser_console
correctly return UTF-8 Chinese content from GitHub pages.

Fix GBK codec decode error on Windows when reading browser command output.
Browser commands output UTF-8 but Windows default encoding is GBK,
causing 'gbk codec can't decode byte 0xa6' errors when browsing GitHub.

Add explicit encoding='utf-8', errors='replace' as kwargs to subprocess.Popen
in _run_browser_command, so output is decoded correctly regardless of
system locale.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) labels Apr 23, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the Windows encoding report and focused patch.

  • Current main writes browser subprocess output to raw stdout/stderr files at tools/browser_tool.py:2444-2450 and performs the decode explicitly at tools/browser_tool.py:2477-2480 with encoding="utf-8".
  • This removes dependence on the Windows system locale for the UTF-8 browser output described in the report.
  • The current implementation was present in d682f320b35a13084371a541a835e1d988c982b8; the proposed Popen location has since been superseded by that file-output path.

Closing as implemented on main. This is an automated hermes-sweeper review.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants