On Tue, 16 Mar 2021 11:44:13 +0900 Inada Naoki <songofaca...@gmail.com> wrote: > Hi, all. > > I found .pth file is decoded by the default (i.e. locale-specific) encoding. > https://github.com/python/cpython/blob/0269ce87c9347542c54a653dd78b9f60bb9fa822/Lib/site.py#L173 > > pth files contain: > > * import statements > * paths > > For import statement, UTF-8 is the default Python code encoding. > For paths, fsencoding is the right encoding. It is UTF-8 on Windows > (excpet PYTHONLEGACYWINDOWSFSENCODING is set), and locale-specific > encoding in Linux. > > What encoding should we use? > > * UTF-8 > * sys.getfilesystemencoding() > * Keep status-quo.
You could add special markup to specify utf8 encoding: # -*- encoding: utf8 -*- If no markup is present, use locale encoding. If markup is present, use utf8 encoding. Bail out if markup specifies something else than utf8. Then update all pth-producing tools to write utf8-encoded pth files (at least on the Python versions that support the encoding markup). In 15 years, you can switch to utf8 by default. Regards Antoine. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/J2IM4IQ3L3XEN6XBRFSDLQ2S2FORN3PP/ Code of Conduct: http://python.org/psf/codeofconduct/