[issue43733] PEP 597: netrc uses locale encoding.

Inada Naoki report at bugs.python.org
Wed Apr 14 04:11:15 EDT 2021


Inada Naoki <songofacandy at gmail.com> added the comment:

I googled "netrc UnicodeDecodeError". It is very rare, but I found two cases.

* https://stackoverflow.com/questions/54748450/macos-python-3-netrc-operations-end-up-with-unicodedecodeerror
  This user uses macOS and Python tried UTF-8. But .netrc was not UTF-8.

* https://qiita.com/yuji38kwmt/items/5472c98cb800ccaab093
  This user uses Windows. They write .netrc with UTF-8, but Python used cp932.

---

There are several options:

* Use UTF-8. If user encountered UnicodeDecodeError, user need to change the .netrc encoding.
* Use UTF-8 with "surrogateescape" or "replace" error handler. non-UTF-8 in comments are ignored.
* Use latin-1. non-ASCII characters in comments are ignored.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43733>
_______________________________________


More information about the Python-bugs-list mailing list