test(tools): support Python 3.10 in encoding regressions #4361

Merged
Roojool merged 1 commit from upstream-pr/4361 into main 2026-10-12 18:20:31 +00:00
Roojool commented 2026-10-12 07:33:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-12T07:33:20Z.


What

pr_overlap_encoding errors on Python 3.10 before testing any Unicode handling: its command_output context manager patches subprocess._text_encoding, which that interpreter does not provide. A native Windows run on main produced eight AttributeError errors. The same limitation is recorded in the validation results of #3986, #1764, #1786 and #2391.

Keep the existing CP1252 simulation on newer interpreters. On Python 3.10, intercept the io.TextIOWrapper locale encoding that Popen actually uses. Explicit UTF-8 arguments still pass through unchanged. A real subprocess test checks the exact CP1252-decoded output when no encoding is supplied and exact Unicode output when UTF-8 is supplied. No nonexistent mock attribute is created.

Only tools/tests/test_pr_overlap_encoding.py changes. Production UTF-8 handling from the previous fixes remains unchanged; this repairs the regression tests rather than reimplementing those fixes. No dependency added. Authored by Rujul Talekar with Muse Spark 1.3 and Codex assistance. This is developer test-suite compatibility, with no title or new CI-failure claim.

Tested

Baseline: 2ca6198e9a43424c2417f2c4c000ecd3d141811a. Rebased onto main 436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113 and repeated final validation.

  • Native Windows, Python 3.10.11: unchanged baseline python -m unittest tools.tests.test_pr_overlap_encoding -v fails with eight errors, AttributeError: module 'subprocess' has no attribute '_text_encoding'. With the fix, 11/11 pass.
  • Linux via WSL2 Ubuntu, Python 3.14.4: the same fixed encoding suite 11/11 passes. The baseline failure concerns Python 3.10; no Linux baseline failure is claimed.
  • Final neighboring validation on both systems, 29/29 pass: python -m unittest tools.tests.test_pr_overlap tools.tests.test_pr_overlap_dependencies tools.tests.test_pr_overlap_encoding tools.tests.test_pr_overlap_exports -v (python3 on Linux).
  • In a disposable copy outside the repository, removing production's explicit UTF-8 arguments makes the simulation fail on both platforms: Linux raises UnicodeDecodeError; Windows's reader thread raises the decode error and the caller rejects the missing output. Unmodified production decodes exactly on both. The source branch's production file was never altered.
  • python tools/check_conventions.py --base upstream/main --head HEAD: passed. git diff --check: passed.
  • No full C++ rebuild or title/GPU runs; this changes one Python test file. Tested interpreter versions are 3.10 and 3.14; older interpreters were not checked.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4826307792 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4361). Originally posted by [Roojool](https://github.com/Roojool) on 2026-10-12T07:33:20Z. --- ### What `pr_overlap_encoding` errors on Python 3.10 before testing any Unicode handling: its `command_output` context manager patches `subprocess._text_encoding`, which that interpreter does not provide. A native Windows run on main produced eight `AttributeError` errors. The same limitation is recorded in the validation results of #3986, #1764, #1786 and #2391. Keep the existing CP1252 simulation on newer interpreters. On Python 3.10, intercept the `io.TextIOWrapper` locale encoding that `Popen` actually uses. Explicit UTF-8 arguments still pass through unchanged. A real subprocess test checks the exact CP1252-decoded output when no encoding is supplied and exact Unicode output when UTF-8 is supplied. No nonexistent mock attribute is created. Only `tools/tests/test_pr_overlap_encoding.py` changes. Production UTF-8 handling from the previous fixes remains unchanged; this repairs the regression tests rather than reimplementing those fixes. No dependency added. Authored by Rujul Talekar with Muse Spark 1.3 and Codex assistance. This is developer test-suite compatibility, with no title or new CI-failure claim. ### Tested Baseline: `2ca6198e9a43424c2417f2c4c000ecd3d141811a`. Rebased onto main `436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113` and repeated final validation. - Native Windows, Python 3.10.11: unchanged baseline `python -m unittest tools.tests.test_pr_overlap_encoding -v` fails with eight errors, `AttributeError: module 'subprocess' has no attribute '_text_encoding'`. With the fix, **11/11 pass**. - Linux via WSL2 Ubuntu, Python 3.14.4: the same fixed encoding suite **11/11 passes**. The baseline failure concerns Python 3.10; no Linux baseline failure is claimed. - Final neighboring validation on both systems, **29/29 pass**: `python -m unittest tools.tests.test_pr_overlap tools.tests.test_pr_overlap_dependencies tools.tests.test_pr_overlap_encoding tools.tests.test_pr_overlap_exports -v` (`python3` on Linux). - In a disposable copy outside the repository, removing production's explicit UTF-8 arguments makes the simulation fail on both platforms: Linux raises `UnicodeDecodeError`; Windows's reader thread raises the decode error and the caller rejects the missing output. Unmodified production decodes exactly on both. The source branch's production file was never altered. - `python tools/check_conventions.py --base upstream/main --head HEAD`: passed. `git diff --check`: passed. - No full C++ rebuild or title/GPU runs; this changes one Python test file. Tested interpreter versions are 3.10 and 3.14; older interpreters were not checked. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-12 07:33:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T07:33:26Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5487692526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4361#pullrequestreview-5487692526). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-12T07:33:26Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MarcZX10 commented 2026-10-12 07:39:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T07:39:01Z.


I ran the focused overlap encoding and neighboring regression tests locally on Linux/Python 3.11: 29/29 passed. The conventions check and git diff --check also pass. This exercises Python 3.11’s _text_encoding branch; I did not run Python 3.10 locally. The CPython 3.10 subprocess.Popen implementation sets the default encoding to "locale" before constructing its TextIOWrapper, which matches the fallback branch added here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6119883123 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4361#issuecomment-6119883123). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T07:39:01Z. --- I ran the focused overlap encoding and neighboring regression tests locally on Linux/Python 3.11: 29/29 passed. The conventions check and `git diff --check` also pass. This exercises Python 3.11’s `_text_encoding` branch; I did not run Python 3.10 locally. The CPython 3.10 `subprocess.Popen` implementation sets the default encoding to `"locale"` before constructing its `TextIOWrapper`, which matches the fallback branch added here.
Zurisen commented 2026-10-12 18:18:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-12T18:18:17Z.


Native Windows run of e991645c merged into main 2a5eca11 (Windows 11 Home 26200), with Python 3.10.11 and 3.12.10:

  • tools/tests/test_pr_overlap_encoding.py: 11/11 on both (on main, 3.10 errors in every case with AttributeError: ... '_text_encoding').
  • Guard check: with encoding="utf-8" removed from pr_overlap.gh, it fails on both (test_gh_json_preserves_unicode errors, test_gh_error_preserves_unicode fails), so the regression stays covered on 3.10.

A smaller variant, if you want one, with no version branch or io.TextIOWrapper patch: the fake subprocess.run in command_output can give a text-mode call without an encoding cp1252 itself, which is what a cp1252 default locale does on every version:

def run(command, **kwargs):
    if kwargs.get("text") or kwargs.get("universal_newlines"):
        kwargs.setdefault("encoding", "cp1252")
    return RUN([sys.executable, "-c", code], **kwargs)

With that in place of the _text_encoding patch, the same 10 cases pass on 3.10 and 3.12 and fail the same way without encoding= (commit 2ba0da75 on Zurisen:fix/pr-overlap-test-python310). Your version is fine as is; this is only if a reviewer prefers fewer moving parts.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130034922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4361#issuecomment-6130034922). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-12T18:18:17Z. --- Native Windows run of `e991645c` merged into `main` `2a5eca11` (Windows 11 Home 26200), with Python 3.10.11 and 3.12.10: - `tools/tests/test_pr_overlap_encoding.py`: 11/11 on both (on `main`, 3.10 errors in every case with `AttributeError: ... '_text_encoding'`). - Guard check: with `encoding="utf-8"` removed from `pr_overlap.gh`, it fails on both (`test_gh_json_preserves_unicode` errors, `test_gh_error_preserves_unicode` fails), so the regression stays covered on 3.10. A smaller variant, if you want one, with no version branch or `io.TextIOWrapper` patch: the fake `subprocess.run` in `command_output` can give a text-mode call without an encoding cp1252 itself, which is what a cp1252 default locale does on every version: ```python def run(command, **kwargs): if kwargs.get("text") or kwargs.get("universal_newlines"): kwargs.setdefault("encoding", "cp1252") return RUN([sys.executable, "-c", code], **kwargs) ``` With that in place of the `_text_encoding` patch, the same 10 cases pass on 3.10 and 3.12 and fail the same way without `encoding=` (commit `2ba0da75` on `Zurisen:fix/pr-overlap-test-python310`). Your version is fine as is; this is only if a reviewer prefers fewer moving parts.
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!4361
No description provided.