fix(tools): write overlap reports as UTF-8 #2134

Merged
MarcZX10 merged 1 commit from upstream-pr/2134 into main 2026-10-10 05:36:41 +00:00
MarcZX10 commented 2026-10-09 09:46:54 +00:00 (Migrated from github.com)

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


What

Write --out overlap reports with an explicit UTF-8 encoding. The decoding fix in #1989 preserves Unicode pull-request metadata, but Path.write_text otherwise uses the Windows locale and can raise UnicodeEncodeError for metadata outside that code page. This change adds a focused regression test for the output bytes.

Relationship to #1741

#1741 adds definition-aware export detection and its CMake test registration. This PR changes report serialization and its encoding test. They touch the same Python module but implement independent behavior; neither depends on the other.

Relationship to #988

#988 adds workflow logging and job summaries. This PR fixes the encoding used for report files. These changes do not duplicate behavior, though both touch the report-writing code; if either merges first, retain the explicit UTF-8 encoding in the resulting writer.

Tested

  • Rebased linearly onto upstream main at 27965d8a; the full diff is limited to tools/pr_overlap.py and tools/tests/test_pr_overlap_encoding.py.
  • Linux x86-64, Python 3.11: python3 tools/tests/test_pr_overlap_encoding.py passes (9/9) and python3 tools/tests/test_pr_overlap.py passes (3/3) on this head.
  • On native Windows 11/Python 3.14.3 with cp1252 and UTF-8 mode off, a direct Path.write_text call without an encoding reproduced UnicodeEncodeError; explicit UTF-8 encoding succeeded. The focused test passed 9/9 on the pre-rebase source, whose change is unchanged by this rebase. The CLI was not run end-to-end because it requires gh.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass.
  • Eligibility, Conventions, and all three relinker jobs pass on this head. The automated PR workflow skipped the full Linux and Windows Build jobs; an authorized collaborator must start Build for those under #2113.

Checklist

  • Based on current main; no open PR implements report-file UTF-8 encoding
  • One topic per PR; follow-up to merged #1989
  • No code comments or silent stubs added
  • No notes, reports, images or third-party code added
  • Generic behavior
  • Depends on: none; relationships to #1741 and #988 are described above
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798775074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2134). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T09:46:54Z. --- ### What Write `--out` overlap reports with an explicit UTF-8 encoding. The decoding fix in #1989 preserves Unicode pull-request metadata, but `Path.write_text` otherwise uses the Windows locale and can raise `UnicodeEncodeError` for metadata outside that code page. This change adds a focused regression test for the output bytes. ### Relationship to #1741 #1741 adds definition-aware export detection and its CMake test registration. This PR changes report serialization and its encoding test. They touch the same Python module but implement independent behavior; neither depends on the other. ### Relationship to #988 #988 adds workflow logging and job summaries. This PR fixes the encoding used for report files. These changes do not duplicate behavior, though both touch the report-writing code; if either merges first, retain the explicit UTF-8 encoding in the resulting writer. ### Tested - Rebased linearly onto upstream `main` at `27965d8a`; the full diff is limited to `tools/pr_overlap.py` and `tools/tests/test_pr_overlap_encoding.py`. - Linux x86-64, Python 3.11: `python3 tools/tests/test_pr_overlap_encoding.py` passes (9/9) and `python3 tools/tests/test_pr_overlap.py` passes (3/3) on this head. - On native Windows 11/Python 3.14.3 with cp1252 and UTF-8 mode off, a direct `Path.write_text` call without an encoding reproduced `UnicodeEncodeError`; explicit UTF-8 encoding succeeded. The focused test passed 9/9 on the pre-rebase source, whose change is unchanged by this rebase. The CLI was not run end-to-end because it requires `gh`. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` pass. - Eligibility, Conventions, and all three relinker jobs pass on this head. The automated PR workflow skipped the full Linux and Windows Build jobs; an authorized collaborator must start Build for those under #2113. ### Checklist - [x] Based on current `main`; no open PR implements report-file UTF-8 encoding - [x] One topic per PR; follow-up to merged #1989 - [x] No code comments or silent stubs added - [x] No notes, reports, images or third-party code added - [x] Generic behavior - [x] Depends on: none; relationships to #1741 and #988 are described above - [x] AI-assisted: yes (Codex)
MGXAe commented 2026-10-09 12:50:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MGXAe on 2026-10-09T12:50:44Z.


Tested on native Windows 11 (Python 3.14.3, locale cp1252, UTF-8 mode off), since the description notes Windows wasn't available.

On main, Path.write_text("PR title → 日本語") raises UnicodeEncodeError: 'charmap' codec can't encode character '\u2192' in position 9: character maps to <undefined>; with encoding="utf-8" it succeeds.

  • tools/tests/test_pr_overlap_encoding.py: 9/9 pass on this head (8a8013b3).
  • The new test errors on main's pr_overlap.py (no write_reports).
  • tools/check_conventions.py passes and git diff --check is clean.

I reproduced the write call directly rather than running pr_overlap.py end-to-end, since that needs gh.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081242480 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2134#issuecomment-6081242480). Originally posted by [MGXAe](https://github.com/MGXAe) on 2026-10-09T12:50:44Z. --- Tested on native Windows 11 (Python 3.14.3, locale cp1252, UTF-8 mode off), since the description notes Windows wasn't available. On `main`, `Path.write_text("PR title → 日本語")` raises `UnicodeEncodeError: 'charmap' codec can't encode character '\u2192' in position 9: character maps to <undefined>`; with `encoding="utf-8"` it succeeds. - `tools/tests/test_pr_overlap_encoding.py`: 9/9 pass on this head (`8a8013b3`). - The new test errors on `main`'s `pr_overlap.py` (no `write_reports`). - `tools/check_conventions.py` passes and `git diff --check` is clean. I reproduced the write call directly rather than running `pr_overlap.py` end-to-end, since that needs `gh`.
MarcZX10 commented 2026-10-09 13:48:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T13:48:22Z.


Rebased the single UTF-8 report change onto current upstream main d70b8998; new head: 89b2ea29da630bdad604a50ec008f5e94967b239. Local focused test passes 9/9, local Conventions and diff checks pass, and the exact-head upstream Conventions check is green. I updated the PR description with the Windows report and its scope: the direct encoding check was not an end-to-end CLI run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6082230975 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2134#issuecomment-6082230975). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T13:48:22Z. --- Rebased the single UTF-8 report change onto current upstream `main` `d70b8998`; new head: `89b2ea29da630bdad604a50ec008f5e94967b239`. Local focused test passes 9/9, local Conventions and diff checks pass, and the exact-head upstream Conventions check is green. I updated the PR description with the Windows report and its scope: the direct encoding check was not an end-to-end CLI run.
MarcZX10 commented 2026-10-09 19:41:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T19:41:22Z.


Validation on the updated head

I rebased the existing branch linearly onto upstream main at 8b393b6e and pushed head 20dbe58a. The full diff remains limited to UTF-8 report serialization and its regression test. The focused Python suite passes 9/9 on this head, Conventions and git diff --check pass, and the PR description explains the independent overlap with #1741.

The Windows cp1252 reproduction is from the same source change before rebasing; it was a direct Path.write_text check, not an end-to-end CLI run. The full Linux/Windows Build and relinker matrix still needs a collaborator with write access. Could someone run Actions → Build for PR #2134 on this head?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088002361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2134#issuecomment-6088002361). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T19:41:22Z. --- ### Validation on the updated head I rebased the existing branch linearly onto upstream `main` at `8b393b6e` and pushed head `20dbe58a`. The full diff remains limited to UTF-8 report serialization and its regression test. The focused Python suite passes 9/9 on this head, Conventions and `git diff --check` pass, and the PR description explains the independent overlap with #1741. The Windows cp1252 reproduction is from the same source change before rebasing; it was a direct `Path.write_text` check, not an end-to-end CLI run. The full Linux/Windows Build and relinker matrix still needs a collaborator with write access. Could someone run Actions → Build for PR #2134 on this head?
Sign in to join this conversation.
No reviewers
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!2134
No description provided.