Skip to content

[3.15] gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410) - #156592

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-b4aea41-3.15
Open

[3.15] gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410)#156592
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-b4aea41-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

It was hard coded to map file descriptors 0, 1 and 2 to the console code
page, but a console can be opened as any file descriptor, and other
character devices, like NUL, are not consoles.

The file handle is now queried. The UTF-8 code page is also now reported
as "utf-8" instead of "cp65001".
(cherry picked from commit b4aea41)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…ythonGH-155410)

It was hard coded to map file descriptors 0, 1 and 2 to the console code
page, but a console can be opened as any file descriptor, and other
character devices, like NUL, are not consoles.

The file handle is now queried.  The UTF-8 code page is also now reported
as "utf-8" instead of "cp65001".
(cherry picked from commit b4aea41)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants