This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PYTHONLEGACYWINDOWSIOENCODING isn't implemented
Type: behavior Stage: resolved
Components: Documentation, IO, Unicode, Windows Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, docs@python, eryksun, ezio.melotti, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords:

Created on 2017-03-24 22:34 by eryksun, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1576 merged berker.peksag, 2017-05-14 05:46
PR 1609 merged berker.peksag, 2017-05-16 16:19
Messages (6)
msg290240 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-03-24 22:34
The environment variable PYTHONLEGACYWINDOWSIOENCODING is documented here:

https://docs.python.org/3/using/cmdline.html#envvar-PYTHONLEGACYWINDOWSIOENCODING

but not actually implemented. Also, I think setting PYTHONIOENCODING to anything except UTF-8 should disable using io._WindowsConsoleIO.
msg290357 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-03-24 23:34
It's actually called "PYTHONLEGACYWINDOWSSTDIO" in Python/pylifecycle.c, which is also what PEP 528 says it should be, so this is a docs issue.

You're correct that PYTHONIOENCODING is overridden by detection of a real console, however, PYTHONIOENCODING doesn't currently set a flag anywhere, and the (required for compatibility) defaults on Windows would make it look like it's always been set to something else.

In my opinion, you should set PYTHONLEGACYWINDOWSSTDIO to indicate that even though we know the incoming encoding (Unicode from an interactive console), you don't care and you want to override it with a default value. Then use PYTHONIOENCODING to set that default value. This is most consistent with the existing use of PYTHONIOENCODING (it's the default unless you know exactly which encoding you are getting).
msg290467 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-03-25 07:42
I prefer the name PYTHONLEGACYWINDOWSIOENCODING for symmetry with both PYTHONIOENCODING and PYTHONLEGACYWINDOWSFSENCODING, but I suppose you changed it to make it more visually distinguished from the latter.

I discovered this issue due to the modified behavior of PYTHONIOENCODING. It's not really a disruptive change, but it looks wrong based solely on the --help text description of PYTHONIOENCODING. An alternative would be to set Py_LegacyWindowsStdioFlag in _Py_InitializeEx_Private either when PYTHONLEGACYWINDOWSSTDIO is set or when PYTHONIOENCODING isn't a case-insensitive match for "utf-8" with an optional :errors spec. That way people get exactly what they asked for, even if it's mojibake nonsense given the console's current input and output codepages.
msg290489 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-03-25 17:05
Sure, but you're proposing a change to a correctly documented (apart from the variable name) and released behavior. It can't be changed in 3.6, and I don't see a compelling reason to have different behavior in 3.7.
msg293756 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-05-16 09:36
New changeset 87fa8a780e9045a26c735f085c07bba4b2d0be60 by Berker Peksag in branch 'master':
bpo-29898: Fix incorrect env variable name (GH-1576)
https://github.com/python/cpython/commit/87fa8a780e9045a26c735f085c07bba4b2d0be60
msg293798 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-05-16 21:31
New changeset 0d267041c40a3ab655676b885c0ba35ed9685848 by Berker Peksag in branch '3.6':
bpo-29898: Fix incorrect env variable name (GH-1576)
https://github.com/python/cpython/commit/0d267041c40a3ab655676b885c0ba35ed9685848
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74084
2017-05-16 21:32:02berker.peksagsetstatus: open -> closed
resolution: fixed
stage: backport needed -> resolved
2017-05-16 21:31:42berker.peksagsetmessages: + msg293798
2017-05-16 16:19:28berker.peksagsetpull_requests: + pull_request1700
2017-05-16 09:37:09berker.peksagsetstage: test needed -> backport needed
2017-05-16 09:36:49berker.peksagsetnosy: + berker.peksag
messages: + msg293756
2017-05-14 05:46:41berker.peksagsetpull_requests: + pull_request1669
2017-03-25 17:05:16steve.dowersetmessages: + msg290489
2017-03-25 07:42:54eryksunsetmessages: + msg290467
2017-03-24 23:34:25steve.dowersetnosy: + docs@python
messages: + msg290357

assignee: docs@python
components: + Documentation
2017-03-24 22:34:03eryksuncreate