[Python-Dev] File system path encoding on Windows

Victor Stinner victor.stinner at gmail.com
Mon Aug 29 19:22:32 EDT 2016


2016-08-24 17:44 GMT+02:00 Steve Dower <steve.dower at python.org>:
> I know Nick and Victor like the idea of a -X flag (or a direct -utf8 flag),
> but I prefer more specific environment variables:
>
> - PYTHONWINDOWSLEGACYSTDIO (for the console changes)
> - PYTHONWINDOWSLEGACYPATHENCODING (assuming getfilesystemencoding() is utf8)
> - PYTHONWINDOWSLEGACYLOCALEENCODING (assuming getpreferredencoding() is
> utf8)

Hum, you propose the opposite behaviour of my proposed "-X utf8"
switch :-) You propose to force UTF-8 by default, but add a new flag
to revert to the old behaviour. Right?

About (...)LEGACYSTDIO: I don't think that we need such option. Using
Unicode is the obvious choice if stdout/stderr is the Windows console
no? I'm not talking about the case where stdout/stderr is redirected
(into a file or a pipe). Are you aware of any case where the "legacy
stdio" is better than the "new" (win_unicode_console-like) stdio?

(...)PATHENCODING and (...)LOCALEENCODING: please don't do that. I
tried once in Python 3.2 on Linux, and it failed badly:
https://mail.python.org/pipermail/python-dev/2010-October/104517.html

I don't think that it's a good idea to add an option to use two
different encodings inside the same process. It's too common to
exchange data between the "path encoding world" and "locale encoding
world".

Hum, currently, is it possible to get two different encodings for
"path encoding" and "locale encoding"? Or both encodings are the ANSI
code page? I only recall that the console uses a different encoding,
the OEM code page.

Victor


More information about the Python-Dev mailing list