According to What's New in Python 3.0 ,
There is a platform-specific default encoding [...] In many cases, but not all, the default is UTF-8; you should never count on this default value.
and
PEP 3120: The default source encoding is now UTF-8.
In other words, Python opens source files by default as UTF-8, but any interaction with the file system will depend on the environment. It is strongly recommended that you use open(filename, encoding='utf-8') to read the file.
Another change is that b'bytes'.decode() and 'str'.encode() with no argument use utf-8 instead of ascii.
Python 3.6 changes a few more default values:
PEP 529: Change Windows File System Encoding to UTF-8
PEP 528: Changing the Encoding of a Windows Console to UTF-8
But the default encoding for open() is still all that Python can get out of the environment.
It looks like 3.7 will add a (opt-in!) Mode in which the coding of the ecological locale is ignored, and all of UTF-8 is all the time (except in specific cases where Windows uses UTF-16, I suppose), see PEP 0540 and corresponding issue 29240 .
source share