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.

Author smallbigcake
Recipients docs@python, smallbigcake
Date 2021-02-06.05:16:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612588574.22.0.21834147948.issue43140@roundup.psfhosted.org>
In-reply-to
Content
In the document about build-in function open() https://docs.python.org/3/library/functions.html#open, it says that
"encoding is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent (whatever locale.getpreferredencoding() returns), but any text encoding supported by Python can be used. See the codecs module for the list of supported encodings.
"
But as I tried, I found that after I set locale using locale.setlocale(), the default encoding used by open() was changed and thus sometimes led to a UnicodeDecodeError.

So I think that the default encoding used by open() is the second element of whatever locale returned by locale.getlocale().
History
Date User Action Args
2021-02-06 05:16:14smallbigcakesetrecipients: + smallbigcake, docs@python
2021-02-06 05:16:14smallbigcakesetmessageid: <1612588574.22.0.21834147948.issue43140@roundup.psfhosted.org>
2021-02-06 05:16:14smallbigcakelinkissue43140 messages
2021-02-06 05:16:13smallbigcakecreate