Skip to content

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

Merged
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-b4aea41-3.14
Aug 29, 2026
Merged

[3.14] gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410)#156596
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-b4aea41-3.14

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 29, 2026

Copy link
Copy Markdown
Member

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)

The test is added to Lib/test/test_os.py, because Lib/test/test_os/test_windows.py does not exist in 3.14.

…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)
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 29, 2026 18:25
@serhiy-storchaka
serhiy-storchaka merged commit 7755fce into python:3.14 Aug 29, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant