Repository navigation
test(tools): support Python 3.10 in encoding regressions - #4361
Conversation
…rlap tests command_output patched subprocess._text_encoding, which does not exist on Python 3.10, so all eight tests errored before their assertions. Use subprocess._text_encoding where available and map io.TextIOWrapper locale to cp1252 on older interpreters, so a subprocess with no explicit encoding decodes as cp1252 on both. Add a behavioral check that default decodes as cp1252 while explicit utf-8 stays correct. Authored by Rujul Talekar, with Muse Spark 1.3 assistance.
|
I ran the focused overlap encoding and neighboring regression tests locally on Linux/Python 3.11: 29/29 passed. The conventions check and |
|
Native Windows run of
A smaller variant, if you want one, with no version branch or 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 |
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)