This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, r.david.murray, serhiy.storchaka, vstinner
Date 2013-09-28.19:23:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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'.
Date User Action Args
2013-09-28 19:23:29vstinnersetrecipients: + vstinner, pitrou, r.david.murray, serhiy.storchaka
2013-09-28 19:23:29vstinnersetmessageid: <>
2013-09-28 19:23:29vstinnerlinkissue19058 messages
2013-09-28 19:23:29vstinnercreate