[issue17110] sys.argv docs should explaining how to handle encoding issues

Inada Naoki report at bugs.python.org
Thu Jun 18 07:19:04 EDT 2020


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

>
> Manuel Jacob <me at manueljacob.de> added the comment:
>
> If the encoding supports it, since which Python version do
> Py_DecodeLocale() and os.fsencode() roundtrip?
>

Maybe, since Python 3.2. FWIW, fsencode is added by Victor in
https://bugs.python.org/issue8514

> The background of my question is that Mercurial goes some extra rounds to
> determine the correct encoding to emulate what Py_EncodeLocale() would do:
> https://www.mercurial-scm.org/repo/hg/file/5.4.1/mercurial/pycompat.py#l157
> . If os.fsencode() could be used, it would simplify the code. Mercurial
> supports Python 3.5+.
>
>
>

I think it is a right approach.
One of the important use case of os.fsencode is using file path from
sys.argv even if it can not be decoded by filesystem encoding.

----------

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


More information about the Python-bugs-list mailing list