[Python-ideas] Fix default encodings on Windows
eryk sun
eryksun at gmail.com
Tue Aug 16 09:09:32 EDT 2016
On Tue, Aug 16, 2016 at 10:53 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>
> Having said all this, I can't find the documentation stating that
> bytes paths are deprecated - the open() documentation for 3.5 says
> "file is either a string or bytes object giving the pathname (absolute
> or relative to the current working directory) of the file to be opened
> or an integer file descriptor of the file to be wrapped" and there's
> no mention of a deprecation.
Bytes paths aren't deprecated on Unix -- only on Windows, and only for
the os functions. You can see the deprecation warning with -Wall:
>>> os.listdir(b'.')
__main__:1: DeprecationWarning: The Windows bytes API has been
deprecated, use Unicode filenames instead
AFAIK this isn't documented.
Since the Windows CRT's _open implementation uses MultiByteToWideChar
without the flag MB_ERR_INVALID_CHARS, bytes paths should also be
deprecated for io.open. The problem is that bad DBCS sequences are
mapped silently to the default Unicode character instead of raising an
error.
More information about the Python-ideas
mailing list