test(tools): support Python 3.10 in encoding regressions #4361
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4361"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-12T07:33:20Z.
What
pr_overlap_encodingerrors on Python 3.10 before testing any Unicode handling: itscommand_outputcontext manager patchessubprocess._text_encoding, which that interpreter does not provide. A native Windows run on main produced eightAttributeErrorerrors. 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.TextIOWrapperlocale encoding thatPopenactually 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.pychanges. 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 main436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113and repeated final validation.python -m unittest tools.tests.test_pr_overlap_encoding -vfails with eight errors,AttributeError: module 'subprocess' has no attribute '_text_encoding'. With the fix, 11/11 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(python3on Linux).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.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)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.
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 --checkalso pass. This exercises Python 3.11’s_text_encodingbranch; I did not run Python 3.10 locally. The CPython 3.10subprocess.Popenimplementation sets the default encoding to"locale"before constructing itsTextIOWrapper, which matches the fallback branch added here.Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-12T18:18:17Z.
Native Windows run of
e991645cmerged intomain2a5eca11(Windows 11 Home 26200), with Python 3.10.11 and 3.12.10:tools/tests/test_pr_overlap_encoding.py: 11/11 on both (onmain, 3.10 errors in every case withAttributeError: ... '_text_encoding').encoding="utf-8"removed frompr_overlap.gh, it fails on both (test_gh_json_preserves_unicodeerrors,test_gh_error_preserves_unicodefails), so the regression stays covered on 3.10.A smaller variant, if you want one, with no version branch or
io.TextIOWrapperpatch: the fakesubprocess.runincommand_outputcan give a text-mode call without an encoding cp1252 itself, which is what a cp1252 default locale does on every version:With that in place of the
_text_encodingpatch, the same 10 cases pass on 3.10 and 3.12 and fail the same way withoutencoding=(commit2ba0da75onZurisen:fix/pr-overlap-test-python310). Your version is fine as is; this is only if a reviewer prefers fewer moving parts.