STINNER Victor added the comment:
> It's doing this now, so seems like it has been fixed: % env -i ./python.exe
> (...)
Right. It's correct to close the issue.
The PEP 540 added a UTF-8 Mode. This mode is enabled if Python is started with
the "C" or "POSIX" locale (LC_CTYPE category). If
Eryk Sun added the comment:
> It's doing this now, so seems like it has been fixed
Yes. In POSIX systems since Python 3.7, if the LC_CTYPE locale is the legacy
"C" or "POSIX" locale, by default it tries to coerce LC_CTYPE to "C.UTF-8",
"C.utf8", or "UTF-8". If coercion fails or is disabled
Irit Katriel added the comment:
It's doing this now, so seems like it has been fixed:
% env -i ./python.exe
Python 3.11.0a0 ...
>>> import os
>>> os.stat(u"\xf0")
Traceback (most recent call last):
File "", line 1, in
FileNotFoundError: [Errno 2] No such file or directory: 'ð'
>>>
New submission from Ondrej Sejvl:
os.stat() raises exception UnicodeEncodeError when path is unicode and no
locale is set in envinronment (this occures when running app with daemon tools
-> LC_ALL=)
How to simulate:
$ env -i python
>>> import os
>>> os.stat(u"\xf0")
Traceback (most recent
R. David Murray added the comment:
I don't think this is "intentional", but instead is a consequence of how things
used to work before we started to try to handle empty/C locale better. It
applies to python3 as well. Since we only started trying to handle this in
python3, I'm not sure that