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

Emil Stenström em at kth.se
Thu Jan 7 14:40:56 EST 2016


Den 2016-01-07 kl. 20:04, skrev Guido van Rossum:
> What policy are you referring to?

I was reading 
https://www.python.org/dev/peps/pep-0387/#backwards-compatibility-rules, 
which specifies "raised exceptions", but I see now that it's only a draft.

 > I don't think anyone objects against
> making the error message clearer. The objection is against rejecting
> unicode strings that in the past would have been successfully encoded
> using Latin-1.

Then I misunderstood, sorry.

> I'm not sure whether it's a good idea to change the exception type from
> TypeError to UnicodeError -- the exception is really related to Unicode
> so keeping UnicodeError but changing the message sounds like the right
> thing to do. And this can be done independently in both Requests and the
> stdlib.

Agreed. I would also suggest adding the suggestion of encoding in 
"utf-8" specifically which is most likely what will fix the problem. As 
time goes by and more and more legacy systems disappear, this advise 
will become truer each year.

/Emil


More information about the Python-ideas mailing list