<p dir="ltr"><br>
On 18 Mar 2014 11:56, "Victor Stinner" <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I modified Python 3.5 to use the "surrogateescape" error handler (PEP<br>
> 383) for stdin and stdout when the LC_CTYPE locale is POSIX ("C"<br>
> locale):<br>
> <a href="http://bugs.python.org/issue19977">http://bugs.python.org/issue19977</a></p>
<p dir="ltr">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).</p>
<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> New behaviour:<br>
> ---<br>
> $ mkdir z<br>
> $ touch z/abcé<br>
> $ LC_CTYPE=C ./python -c 'import os; print(os.listdir("z")[0])'<br>
> abcé<br>
> ---<br>
><br>
> Old behaviour, before the change (test with Python 3.3):<br>
> ---<br>
> $ LC_CTYPE=C python3 -c 'import os; print(os.listdir("z")[0])'<br>
> Traceback (most recent call last):<br>
> File "<string>", line 1, in <module><br>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position<br>
> 3-4: ordinal not in range(128)<br>
> ---<br>
><br>
> The POSIX locale is common because it is used by default when no other<br>
> locale is set. It's common that programs started by a crontab on UNIX<br>
> and daemons are using this locale.<br>
><br>
> Victor<br>
> _______________________________________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-dev">https://mail.python.org/mailman/listinfo/python-dev</a><br>
> Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com">https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com</a><br>
</p>