Skip to content

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

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

fix: add encoding='utf-8', errors='replace' to subprocess.Popen#14553
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
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 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.

2 participants