fix: add encoding='utf-8' to subprocess.run() calls to fix Windows non-UTF-8 locale#409
Open
suainam wants to merge 1 commit intotirth8205:mainfrom
Open
fix: add encoding='utf-8' to subprocess.run() calls to fix Windows non-UTF-8 locale#409suainam wants to merge 1 commit intotirth8205:mainfrom
suainam wants to merge 1 commit intotirth8205:mainfrom
Conversation
…n-UTF-8 locale fix: add encoding='utf-8' to subprocess.run() calls to fix Windows non-UTF-8 locale
dpesch
added a commit
to 11com7/code-review-graph
that referenced
this pull request
May 3, 2026
…dows non-UTF-8 locale)
dpesch
added a commit
to 11com7/code-review-graph
that referenced
this pull request
May 3, 2026
- PR tirth8205#400 (niveku): auto-select ThreadPoolExecutor on Windows MCP stdio to avoid ProcessPool pipe-handle inheritance deadlock; stdin=DEVNULL on all git subprocess calls (closes upstream tirth8205#46, tirth8205#136, tirth8205#401) - PR tirth8205#409 (suainam): encoding='utf-8' on subprocess.run() calls for Windows non-UTF-8 locales (GBK, Shift-JIS, etc.) These are pending upstream review. Merged here for internal use.
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 Encoding Issue in subprocess.run() Calls
Problem
The
code-review-graph buildcommand fails on Windows systems with non-UTF-8 default encoding (e.g., Chinese Windows with GBK, Japanese Windows with Shift-JIS).Error Message
Root Cause
In
incremental.py, allsubprocess.run()calls usetext=Truewithout specifyingencoding='utf-8':When
text=Trueis used without an explicit encoding:UnicodeDecodeErrorresult.stdoutbecomesNone.splitlines()onNoneAffected Code Locations
All
subprocess.run()calls inincremental.py:get_all_tracked_files()-git ls-filesget_changed_files()-git diffget_file_content_at_commit()-git showImpact
Solution
Add
encoding='utf-8'parameter to allsubprocess.run()calls:Proposed Changes
File:
code_review_graph/incremental.pyReplace all occurrences of:
With:
This ensures consistent UTF-8 decoding across all platforms.
Testing
Before Fix
After Fix
Workaround (Current)
Users on affected systems can use this workaround script:
Additional Notes
subprocessdocumentation recommends explicit encoding for cross-platform compatibilitysubprocess.run()withtext=TrueReferences
Environment:
Reproduction:
code-review-graph buildin any git repositoryExpected behavior:
Graph builds successfully regardless of system encoding.
Actual behavior:
Build fails with encoding error on non-UTF-8 Windows systems.