Martin Panter added the comment:
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?
----------
Added file: http://bugs.python.org/file41768/utfpatch.v2.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26045>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com