tools: pr_overlap crashes on Unicode PR metadata on Windows #1949

Closed
opened 2026-10-09 01:45:40 +00:00 by arcwiser · 2 comments
arcwiser commented 2026-10-09 01:45:40 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-10-09T01:45:40Z.


What

Running the documented overlap checker on Windows can crash before it compares any branches when an open pull-request body contains a character that is not representable in the active legacy code page. gh emits UTF-8, but subprocess.run(..., text=True) in gh() decodes with the process locale (cp1252 here).

Observed from current main while checking branch 3058b519:

Exception in thread Thread-1 (_readerthread):
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 8577: character maps to <undefined>
...
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Command:

python tools/pr_overlap.py --branch HEAD --repo boykopovar/AnyPS5

Setting PYTHONUTF8=1 makes the same command complete. The tool should explicitly decode gh output as UTF-8 instead of depending on the caller's locale. Git output may need the same treatment for Unicode paths or commit data.

I did not open a patch because PR #1741 already edits tools/pr_overlap.py; this should be handled there or in a follow-up after it merges to avoid conflicting work.

Environment: Windows, Python 3.10.11, active code page behavior cp1252.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5771468994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1949). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-10-09T01:45:40Z. --- ### What Running the documented overlap checker on Windows can crash before it compares any branches when an open pull-request body contains a character that is not representable in the active legacy code page. `gh` emits UTF-8, but `subprocess.run(..., text=True)` in `gh()` decodes with the process locale (cp1252 here). Observed from current `main` while checking branch `3058b519`: ```text Exception in thread Thread-1 (_readerthread): UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 8577: character maps to <undefined> ... TypeError: the JSON object must be str, bytes or bytearray, not NoneType ``` Command: ```powershell python tools/pr_overlap.py --branch HEAD --repo boykopovar/AnyPS5 ``` Setting `PYTHONUTF8=1` makes the same command complete. The tool should explicitly decode `gh` output as UTF-8 instead of depending on the caller's locale. Git output may need the same treatment for Unicode paths or commit data. I did not open a patch because PR #1741 already edits `tools/pr_overlap.py`; this should be handled there or in a follow-up after it merges to avoid conflicting work. Environment: Windows, Python 3.10.11, active code page behavior cp1252. AI-assisted: yes.
MarcZX10 commented 2026-10-09 03:56:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T03:56:16Z.


Two PRs now address this issue: #1989 adds explicit UTF-8 decoding for gh, git, and merge-tree plus registered cp1252 regression tests; #1990 makes the same decoding change and also writes report files as UTF-8. I asked both authors to coordinate so the regression coverage and report-writing fix land together in one PR. #1990’s Windows job and conventions pass; its Linux job is still running. #1989 currently has no reported checks.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073946709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1949#issuecomment-6073946709). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T03:56:16Z. --- Two PRs now address this issue: #1989 adds explicit UTF-8 decoding for `gh`, `git`, and `merge-tree` plus registered cp1252 regression tests; #1990 makes the same decoding change and also writes report files as UTF-8. I asked both authors to coordinate so the regression coverage and report-writing fix land together in one PR. #1990’s Windows job and conventions pass; its Linux job is still running. #1989 currently has no reported checks.
MarcZX10 commented 2026-10-09 09:47:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:47:10Z.


The deferred report-writing follow-up is now in #2134. It sets encoding="utf-8" for --out report files and extends the existing pr_overlap_encoding regression suite. The check passes on Linux and directly asserts the encoding argument, so it covers the Windows code-page requirement; native Windows execution is still unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078484987 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1949#issuecomment-6078484987). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T09:47:10Z. --- The deferred report-writing follow-up is now in #2134. It sets `encoding="utf-8"` for `--out` report files and extends the existing `pr_overlap_encoding` regression suite. The check passes on Linux and directly asserts the encoding argument, so it covers the Windows code-page requirement; native Windows execution is still unverified.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#1949
No description provided.