STINNER Victor added the comment:

> Here is a patch. It uses same algorithm to obtain encodable
> non-ASCII string as for FS_NONASCII, but with locale encoding.
> It also adds new tests and simplifies existing tests.

I don't like your patch. The purpose of PYTHONIOENCODING is to set 
sys.stdin/stdout/stderr encodings. Your patch does not check 
sys.stdout.encoding, but check directly the codec. Two codecs may encode the 
same character as the same byte sequence.

Your test is skipped if the locale encoding is ASCII, whereas the purpopse of 
PYTHONIOENCODING is to write non-ASCII characters without having to care of the 
locale encoding.

I would really prefer to simply check sys.stdin.encoding, sys.stdout.encoding 
and sys.stderr.encoding attributes.

If you really want to check the codec itself, you should use known sequence, 
ex: 'héllo€'.encode('cp1252') gives b'h\xe9llo\x80'.

----------

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

Reply via email to