GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — test_subprocess: test_getoutput fails on non-English Windows, as text mode decodes cmd.exe's OEM output as UTF-8 · Issue #160652 · python/cpython Open Labels OS-windowstestsTests in the Lib/test dirTests in the Lib/test dirtopic-subprocessSubprocess issues.Subprocess issues. DescriptionBug report
import subprocess, sys subprocess.run([sys.executable, "-c", "import sys; sys.stdout.buffer.write('版本'.encode('cp936'))"], stdout=subprocess.PIPE, text=True).stdout
That is what breaks the test: it runs File "Lib/subprocess.py", line 1382, in communicate stdout = self.stdout.read() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 4: invalid continuation byte On the same machine, Suggested fix (test-side): stop depending on the child's localized text, e.g. Two neighbours, both distinct: gh-158006 (with two pipes the decode error stays in the reader thread and environment and full traceback$ ./PCbuild/amd64/python_d.exe -c "import ctypes,locale,sys;k=ctypes.windll.kernel32;print(k.GetACP(),k.GetOEMCP(),k.GetConsoleOutputCP(),locale.getencoding(),locale.getpreferredencoding(False),sys.flags.utf8_mode)" 936 936 936 cp936 utf-8 1 $ ./PCbuild/amd64/python_d.exe -m test -v test_subprocess -m test_getoutput ERROR: test_getoutput (test.test_subprocess.MiscTests.test_getoutput) File "Lib/test/test_subprocess.py", line 4135, in test_getoutput status, output = subprocess.getstatusoutput( File "Lib/subprocess.py", line 792, in getstatusoutput data = check_output(cmd, shell=True, text=True, stderr=STDOUT, File "Lib/subprocess.py", line 1382, in communicate stdout = self.stdout.read() File "Lib/codecs.py", line 327, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 4: invalid continuation byte Machine: Windows 11 (10.0.26100), zh-CN, CPython built from CPython versions tested on:3.12, 3.14, 3.16, main Operating systems tested on:Windows AI assistance: drafted with deepseek-v4.1-flash in the pi coding agent; every command above was run locally on the machine described, and the text was reviewed by the author before posting. Linked PRsActivity
MetadataMetadataAssigneesLabelsOS-windowstestsTests in the Lib/test dirTests in the Lib/test dirtopic-subprocessSubprocess issues.Subprocess issues. ProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |