fix(tools): write release notes on Python 3.9 #6728

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/6728 into main
MarcZX10 commented 2026-10-16 07:49:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T07:49:52Z.


What

Python 3.9's pathlib.Path.write_text does not accept the newline argument. prepare_notes used it for both output files, making the existing release_package CTest fail on Python 3.9 (including Xcode's bundled Python).

Write the UTF-8 encoded bytes directly instead. This preserves exact LF/CRLF content and avoids platform newline translation. The existing ReleaseNotesTests.test_full_notes_are_preserved_in_asset checks the full and shortened outputs byte-for-byte.

This is independent of #6424's path-alias checks; the two changes touch the same source file but different behavior.

Tested

  • Linux, Python 3.11.2: python3 -I tools/tests/test_package_release.py — 26 tests passed, 3 skipped.
  • python3 tools/check_conventions.py --base upstream/main — passed.
  • Python 3.9 behavior was independently reproduced by reviewers on #6693 and #6424; no Python 3.9 interpreter is installed in my Linux environment.

Checklist

  • Based on current main
  • One topic per PR
  • No code comments or technical-debt changes needed
  • No third-party code or dependencies added
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4885212978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6728). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T07:49:52Z. --- ### What Python 3.9's `pathlib.Path.write_text` does not accept the `newline` argument. `prepare_notes` used it for both output files, making the existing `release_package` CTest fail on Python 3.9 (including Xcode's bundled Python). Write the UTF-8 encoded bytes directly instead. This preserves exact LF/CRLF content and avoids platform newline translation. The existing `ReleaseNotesTests.test_full_notes_are_preserved_in_asset` checks the full and shortened outputs byte-for-byte. This is independent of #6424's path-alias checks; the two changes touch the same source file but different behavior. ### Tested - Linux, Python 3.11.2: `python3 -I tools/tests/test_package_release.py` — 26 tests passed, 3 skipped. - `python3 tools/check_conventions.py --base upstream/main` — passed. - Python 3.9 behavior was independently reproduced by reviewers on #6693 and #6424; no Python 3.9 interpreter is installed in my Linux environment. ### Checklist - [x] Based on current `main` - [x] One topic per PR - [x] No code comments or technical-debt changes needed - [x] No third-party code or dependencies added - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-16 09:33:52 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Ran this with Xcode's Python 3.9 (/usr/bin/python3 3.9.6): Apple M2 Max, macOS 27.2. Head 5db90df6e on main 5d9dcc42d, relinker-only build (-DANYPS5_RELINKER_ONLY=ON).

  • python3 tools/tests/test_package_release.py with 3.9.6: on main, 4 errors (TypeError: write_text() got an unexpected keyword argument 'newline', the test_full_notes_are_preserved_in_asset subtests); with this PR, OK (3 skipped, same as on 3.14).
  • ctest, x86_64 under Rosetta with -DPython3_EXECUTABLE=/usr/bin/python3: main 170/173 (pr_overlap_tools, release_package, linux_fixed_base); release_package passes with this PR. With this PR and #6734 together: 172/173.
  • arm64 (Python 3.14): 173/173 on main and with this PR.

The remaining 3.9 failure, linux_fixed_base, is zip(..., strict=True) in core/relinker/relinker/tests/test_linux_fixed_base.py:107 and is not covered by this PR or #6734.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5545783962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6728#pullrequestreview-5545783962). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T09:33:52Z. **Review:** COMMENTED --- Ran this with Xcode's Python 3.9 (`/usr/bin/python3` 3.9.6): Apple M2 Max, macOS 27.2. Head 5db90df6e on `main` 5d9dcc42d, relinker-only build (`-DANYPS5_RELINKER_ONLY=ON`). - `python3 tools/tests/test_package_release.py` with 3.9.6: on `main`, 4 errors (`TypeError: write_text() got an unexpected keyword argument 'newline'`, the `test_full_notes_are_preserved_in_asset` subtests); with this PR, OK (3 skipped, same as on 3.14). - ctest, x86_64 under Rosetta with `-DPython3_EXECUTABLE=/usr/bin/python3`: `main` 170/173 (`pr_overlap_tools`, `release_package`, `linux_fixed_base`); `release_package` passes with this PR. With this PR and #6734 together: 172/173. - arm64 (Python 3.14): 173/173 on `main` and with this PR. The remaining 3.9 failure, `linux_fixed_base`, is `zip(..., strict=True)` in `core/relinker/relinker/tests/test_linux_fixed_base.py:107` and is not covered by this PR or #6734. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-16 14:07:16 +00:00 (Migrated from github.com)

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


Thanks for the Python 3.9 run and for identifying linux_fixed_base as the remaining failure outside this PR. #6843 removes its Python 3.10-only zip(strict=True) call while keeping an explicit equal-length assertion. I validated the focused test on Linux/Python 3.11; I could not run Python 3.9 locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217276010 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6728#issuecomment-6217276010). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T14:07:16Z. --- Thanks for the Python 3.9 run and for identifying linux_fixed_base as the remaining failure outside this PR. #6843 removes its Python 3.10-only zip(strict=True) call while keeping an explicit equal-length assertion. I validated the focused test on Linux/Python 3.11; I could not run Python 3.9 locally.
adriadam10 commented 2026-10-19 08:04:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:04:55Z.


Closing: main already contains this change (02c7da767, "keep the Python tools and tests on Python 3.9"). tools/prepare_release_notes.py writes both outputs with write_bytes(...encode("utf-8")) there, so this PR's diff against current main is empty. Thanks for the fix and the follow-up; feel free to reopen if something is left that main doesn't cover.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262596690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6728#issuecomment-6262596690). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T08:04:55Z. --- Closing: `main` already contains this change (02c7da767, "keep the Python tools and tests on Python 3.9"). `tools/prepare_release_notes.py` writes both outputs with `write_bytes(...encode("utf-8"))` there, so this PR's diff against current `main` is empty. Thanks for the fix and the follow-up; feel free to reopen if something is left that `main` doesn't cover.

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