[Python-ideas] Fall back to encoding unicode strings in utf-8 if latin-1 fails in http.client

Paul Moore p.f.moore at gmail.com
Thu Jan 7 07:09:23 EST 2016


On 7 January 2016 at 11:53, Chris Angelico <rosuav at gmail.com> wrote:
> 3) Encode as ASCII, and let any errors bubble up.

4) Encode as ASCII and catch UnicodeEncodeError and re-raise as a
TypeError "Unicode string supplied without an explicit encoding".

IMO, the underlying encoding errors are very user-unfriendly, and
should nearly always be caught internally and replaced with something
more user friendly. Most of the user confusion I see from Unicode
issues could probably be significantly alleviated if the user was
presented with something better than a raw (en/de)coding error and
traceback.

Paul


More information about the Python-ideas mailing list