fix(tools): keep overlap tests compatible with Python 3.9 #6734

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/6734 into main
MarcZX10 commented 2026-10-16 08:25:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T08:25:43Z.


What

Path.write_text(..., newline=...) is only available starting in Python 3.10. tools/tests/test_pr_overlap.py is registered with CTest, so these fixture writes raise TypeError when the tool test suite runs on Python 3.9. The three affected fixtures intentionally use exact UTF-8/LF bytes; write them with Path.write_bytes(data.encode("utf-8")) instead.

Python documents the newline parameter as added in 3.10: https://docs.python.org/3.10/library/pathlib.html#pathlib.Path.write_text

Tested

Linux, Python 3.11.2:

  • python3 -m unittest tools.tests.test_pr_overlap -v — 21 tests passed.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD — passed.
  • git diff --check — passed.
  • python3 tools/pr_overlap.py --branch codex/python39-test-fixture-writes — no overlap with open pull requests.

Python 3.9 itself was not available in this environment; compatibility follows from using Path.write_bytes, which predates Python 3.9, and removing the 3.10-only argument. No C++ build was run because this changes only a Python test.

Checklist

  • Based on current main; no other open PR implements the same change
  • One topic per PR; follow-up work goes in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no runtime exports changed
  • No notes, investigation files, or images added to the repository
  • New third-party code is a submodule built from source; n/a
  • Generic test-suite compatibility fix, not title-specific
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4885591238 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T08:25:43Z. --- ### What `Path.write_text(..., newline=...)` is only available starting in Python 3.10. `tools/tests/test_pr_overlap.py` is registered with CTest, so these fixture writes raise `TypeError` when the tool test suite runs on Python 3.9. The three affected fixtures intentionally use exact UTF-8/LF bytes; write them with `Path.write_bytes(data.encode("utf-8"))` instead. Python documents the `newline` parameter as added in 3.10: https://docs.python.org/3.10/library/pathlib.html#pathlib.Path.write_text ### Tested Linux, Python 3.11.2: - `python3 -m unittest tools.tests.test_pr_overlap -v` — 21 tests passed. - `python3 tools/check_conventions.py --base upstream/main --head HEAD` — passed. - `git diff --check` — passed. - `python3 tools/pr_overlap.py --branch codex/python39-test-fixture-writes` — no overlap with open pull requests. Python 3.9 itself was not available in this environment; compatibility follows from using `Path.write_bytes`, which predates Python 3.9, and removing the 3.10-only argument. No C++ build was run because this changes only a Python test. ### Checklist - [x] Based on current `main`; no other open PR implements the same change - [x] One topic per PR; follow-up work goes in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no runtime exports changed - [x] No notes, investigation files, or images added to the repository - [x] New third-party code is a submodule built from source; n/a - [x] Generic test-suite compatibility fix, not title-specific - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-16 09:33:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T09:33:49Z.

Review: COMMENTED


Ran this with the Python 3.9 the description could not test: Apple M2 Max, macOS 27.2, /usr/bin/python3 3.9.6 from Xcode. Head 5d632ec79 on main 5d9dcc42d, relinker-only build (-DANYPS5_RELINKER_ONLY=ON).

  • python3 tools/tests/test_pr_overlap.py with 3.9.6: on main, 3 errors (TypeError: write_text() got an unexpected keyword argument 'newline', all in CommentStateTests); with this PR, 21/21 OK.
  • ctest, x86_64 under Rosetta with -DPython3_EXECUTABLE=/usr/bin/python3: main 170/173 (pr_overlap_tools, release_package, linux_fixed_base); pr_overlap_tools passes with this PR. With this PR and #6728 together: 172/173.
  • arm64 (Python 3.14): 173/173 on main and with this PR.

The one left on 3.9 is linux_fixed_base: core/relinker/relinker/tests/test_linux_fixed_base.py:107 uses zip(..., strict=True) (3.10+), TypeError: zip() takes no keyword arguments. Neither this PR nor #6728 touches it.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5545783538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734#pullrequestreview-5545783538). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T09:33:49Z. **Review:** COMMENTED --- Ran this with the Python 3.9 the description could not test: Apple M2 Max, macOS 27.2, `/usr/bin/python3` 3.9.6 from Xcode. Head 5d632ec79 on `main` 5d9dcc42d, relinker-only build (`-DANYPS5_RELINKER_ONLY=ON`). - `python3 tools/tests/test_pr_overlap.py` with 3.9.6: on `main`, 3 errors (`TypeError: write_text() got an unexpected keyword argument 'newline'`, all in `CommentStateTests`); with this PR, 21/21 OK. - ctest, x86_64 under Rosetta with `-DPython3_EXECUTABLE=/usr/bin/python3`: `main` 170/173 (`pr_overlap_tools`, `release_package`, `linux_fixed_base`); `pr_overlap_tools` passes with this PR. With this PR and #6728 together: 172/173. - arm64 (Python 3.14): 173/173 on `main` and with this PR. The one left on 3.9 is `linux_fixed_base`: `core/relinker/relinker/tests/test_linux_fixed_base.py:107` uses `zip(..., strict=True)` (3.10+), `TypeError: zip() takes no keyword arguments`. Neither this PR nor #6728 touches it. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-16 14:07:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T14:07:15Z.


Thanks for checking this with Xcode’s Python 3.9 and for identifying the remaining linux_fixed_base failure. I opened #6843 for that separate Python compatibility issue. The focused test passes on Linux/Python 3.11 here; Python 3.9 was unavailable locally, so that runtime confirmation is still outstanding.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217275491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734#issuecomment-6217275491). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T14:07:15Z. --- Thanks for checking this with Xcode’s Python 3.9 and for identifying the remaining linux_fixed_base failure. I opened #6843 for that separate Python compatibility issue. The focused test passes on Linux/Python 3.11 here; Python 3.9 was unavailable locally, so that runtime confirmation is still outstanding.
MarcZX10 commented 2026-10-16 15:19:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:19:26Z.

Review: COMMENTED


Thanks for running the Python 3.9 validation. It confirms the fix in this PR removes the three newline= failures on that runtime. Your zip(strict=True) finding was separate; I opened #6843 for that remaining compatibility issue and its focused Linux test plus the hosted macOS/Windows/Linux relinker matrix pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5549839920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734#pullrequestreview-5549839920). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:19:26Z. **Review:** COMMENTED --- Thanks for running the Python 3.9 validation. It confirms the fix in this PR removes the three `newline=` failures on that runtime. Your `zip(strict=True)` finding was separate; I opened #6843 for that remaining compatibility issue and its focused Linux test plus the hosted macOS/Windows/Linux relinker matrix pass.
MarcZX10 commented 2026-10-17 17:52:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T17:52:02Z.


Rebased the PR onto current main (66702f1c) as 916eed7ee. The only conflict was in the fixture write; I preserved main’s current test flow and retained the Python 3.9-compatible write_bytes path. Validation: python3 tools/tests/test_pr_overlap.py passes 21/21, check_conventions.py --base upstream/main passes, and git diff --check passes. The Python 3.9/Xcode run reported earlier remains the platform-specific validation; hosted checks are now running for this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238045509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734#issuecomment-6238045509). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T17:52:02Z. --- Rebased the PR onto current `main` (`66702f1c`) as `916eed7ee`. The only conflict was in the fixture write; I preserved main’s current test flow and retained the Python 3.9-compatible `write_bytes` path. Validation: `python3 tools/tests/test_pr_overlap.py` passes 21/21, `check_conventions.py --base upstream/main` passes, and `git diff --check` passes. The Python 3.9/Xcode run reported earlier remains the platform-specific validation; hosted checks are now running for this head.
oneandonlydean commented 2026-10-18 00:23:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T00:23:04Z.


Thanks for this. Main already fixed the Python 3.9 issue in 02c7da7677, so what's left here no longer changes behaviour. Closing as superseded.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243679705 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6734#issuecomment-6243679705). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T00:23:04Z. --- Thanks for this. Main already fixed the Python 3.9 issue in 02c7da7677e, so what's left here no longer changes behaviour. Closing as superseded.

Pull request closed

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!6734
No description provided.