[Python-Dev] Python 3.5 now uses surrogateescape for the POSIX locale

Nick Coghlan ncoghlan at gmail.com
Tue Mar 18 09:08:08 CET 2014


On 18 Mar 2014 11:56, "Victor Stinner" <victor.stinner at gmail.com> wrote:
>
> Hi,
>
> I modified Python 3.5 to use the "surrogateescape" error handler (PEP
> 383) for stdin and stdout when the LC_CTYPE locale is POSIX ("C"
> locale):
> http://bugs.python.org/issue19977

Yay, thanks Victor. I'll let the Fedora folks know this has been merged, as
we may seriously consider applying this as a vendor patch to our build of
Python 3.4 (while I agree this isn't a bug fix, the current behaviour also
poses a problem for Fedora as more core utilities start migrating to Python
3).

Cheers,
Nick.

>
> New behaviour:
> ---
> $ mkdir z
> $ touch z/abcé
> $ LC_CTYPE=C ./python -c 'import os; print(os.listdir("z")[0])'
> abcé
> ---
>
> Old behaviour, before the change (test with Python 3.3):
> ---
> $ LC_CTYPE=C python3 -c 'import os; print(os.listdir("z")[0])'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 3-4: ordinal not in range(128)
> ---
>
> The POSIX locale is common because it is used by default when no other
> locale is set. It's common that programs started by a crontab on UNIX
> and daemons are using this locale.
>
> Victor
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140318/2fdfb55f/attachment.html>


More information about the Python-Dev mailing list