fix: add encoding='utf-8', errors='replace' to subprocess.Popen#14553
Open
shushuzn wants to merge 1 commit into
Open
fix: add encoding='utf-8', errors='replace' to subprocess.Popen#14553shushuzn wants to merge 1 commit into
shushuzn wants to merge 1 commit into
Conversation
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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Windows GBK encoding error in browser tool
Problem: On Windows,
subprocess.Popendefaults to system encoding (GBK).When reading browser command output from GitHub pages (UTF-8 content), Python
fails with:
Solution: Add
encoding='utf-8', errors='replace'as kwargs tosubprocess.Popenin_run_browser_command.Files changed: Only
tools/browser_tool.py— adds two lines:Testing: Verified on Windows —
browser_navigate+browser_consolecorrectly return UTF-8 Chinese content from GitHub pages.