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

Chris Angelico rosuav at gmail.com
Thu Jan 7 07:29:31 EST 2016


On Thu, Jan 7, 2016 at 11:09 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> 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.

Maybe. Same difference, though - permit ASCII-only, anything else is an error.

ChrisA


More information about the Python-ideas mailing list