GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-160652: Make test_getoutput independent of the console code page by summeriver13 · Pull Request #160664 · python/cpython

Conversation

@summeriver13

@summeriver13 summeriver13 commented Oct 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

test_getoutput fails on Windows whenever the console code page is not UTF-8: getstatusoutput() decodes the shell's localized error message as UTF-8 and raises.

File "Lib/subprocess.py", line 1382, in communicate
    stdout = self.stdout.read()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 4

UTF-8 is correct for Python's side of the pipe — the code page is the child's choice, not Python's — but this test only needs the exit status, so let the decoder replace the bytes it cannot decode. That keeps getstatusoutput() under test instead of switching to run(), as suggested in the issue.
Verified on zh-CN Windows 11 (CP936), current main:

# before
$ ./PCbuild/amd64/python_d.exe -m test test_subprocess -m test_getoutput
FAILED (errors=1)
# after
$ ./PCbuild/amd64/python_d.exe -m test test_subprocess -m test_getoutput
OK
$ ./PCbuild/amd64/python_d.exe -m test test_subprocess
Result: SUCCESS (run=371 skipped=216)

3.12 with -X utf8=1 fails the same way, so the test was encoding-dependent since UTF-8 mode existed; 3.15 only made it the default. Skip news (test only).
AI assistance: drafted with deepseek-v4.1-flash in the pi coding agent; commands above were run locally, text reviewed by the author.

  • Issue: test_subprocess: test_getoutput fails on non-English Windows, as text mode decodes cmd.exe's OEM output as UTF-8 #160652

Fixes #160652

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@summeriver13
pythongh-160652: Make test_getoutput independent of the console code …
204b71a
…page

The shell writes its error message in the console code page, which is not
necessarily the encoding text mode picks (UTF-8 once UTF-8 mode is on).
Only the exit status is checked here, so tolerate undecodable bytes
instead of failing on them.
@summeriver13
summeriver13 requested a review from gpshead as a code owner October 25, 2026 13:37
@bedevere-app bedevere-app Bot added the awaiting review label Oct 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 25, 2026
test_subprocess: test_getoutput fails on non-English Windows, as text mode decodes cmd.exe's OEM output as UTF-8 #160652
Open
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aisk aisk added the skip news label Oct 25, 2026
aisk
aisk approved these changes Oct 25, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aisk aisk aisk approved these changes
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

test_subprocess: test_getoutput fails on non-English Windows, as text mode decodes cmd.exe's OEM output as UTF-8

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@summeriver13 @aisk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.