Message259301
| Author |
martin.panter |
| Recipients |
Emil Stenström, ezio.melotti, gvanrossum, martin.panter, vstinner |
| Date |
2016年01月31日.21:56:57 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1454277418.16.0.549884777131.issue26045@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here is my cut down version of Guido’s patch. Now it only adds the message when someone passes a text string as the HTTPConnection.request(body=...) parameter:
>>> c.request("POST", "", body="Celebrate \U0001F389")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/proj/python/cpython/Lib/http/client.py", line 1098, in request
self._send_request(method, url, body, headers)
File "/home/proj/python/cpython/Lib/http/client.py", line 1142, in _send_request
body = _encode(body, 'body')
File "/home/proj/python/cpython/Lib/http/client.py", line 161, in _encode
(name.title(), data[err.start:err.end], name)) from None
UnicodeEncodeError: 'latin-1' codec can't encode character '\U0001f389' in position 10: Body ('🎉') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.
What do people think? |
|