New submission from Cake Xu <smallbigc...@qq.com>:
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(). ---------- assignee: docs@python components: Documentation messages: 386544 nosy: docs@python, smallbigcake priority: normal severity: normal status: open title: build-in open() doesn't use whatever locale.getpreferredencoding() returns as default encoding. versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43140> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com