Inada Naoki <songofaca...@gmail.com> added the comment:

> I have since changed the PR to use PyUnicode_DecodeFSDefault based on review 
> feedback. I was going to say that you will have to fight it out with @methane 
> on GH, but I see that that's you. :D Would have been nice if you would have 
> left the updated feedback there as well so people who aren't familiar would 
> know it's one person adjusting their recommendation vs two different people 
> with conflicting recommendations.

OK, I changd my b.p.o username.


> The only issue I see with using backslashreplace is that users of non-UTF-8 
> locales would see message text that contains non-ASCII characters only as 
> escape codes. eg, the message above would show "Il modulo dipendente 
> libbz2.so non \xe8 stato caricato." instead of "Il modulo dipendente 
> libbz2.so non รจ stato caricato."

The issue is not caused by backslashreplace, but by UTF-8 instead of locale. I 
notice it of course, but:

* Using UTF-8 is status quo. UTF-8:backslashreplace is the simplest fix 
approach.
* There is no guarantee that the error message can be decoded by locale 
encoding. Backslash escape is much better than "ignore" or "surrogateescape".


> By using PyUnicode_DecodeFSDefault instead, the message should be properly 
> decoded but any encoding errors (such as utf-8 paths, etc) would be handled 
> by surrogateescape.
> 

There is no guranatee that the message is properly decoded with fsencoding.
And surrogateescape is for round-tripping bytes path, not for human readable.
Error message should be human readable. So backslashreplace is better than 
surrogateescape.

Additionally, non-UTF-8 locale is quite rare on Unix systems, and users of such 
systems would be able to handle backslash escaped message, because they might 
see such message often.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41894>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to