facebook/tornado — pull request #945 by chrismcguire (2013-11-25 18:31:56+00:00)
Title: Set HTTPRequest body as utf8.

httpclient.HTTPRequest objects are able to be instantiated with a string body, but if the body of the request was set to a string after instantiation in python 3.3, a TypeError is raised when fetching the request. The issue occurs when it attempts to concatenate the bytes and string body: https://github.com/facebook/tornado/blob/master/tornado/simple_httpclient.py#L333.

This pull request changes body to a property who's setter will call utf8() on body.

An example of the issue is pull request addresses:

``` Python
from tornado.httpclient import (
HTTPClient,
HTTPRequest,
)

# Using HTTPClient here, but the same concept applies to AsyncHTTPClient.
http_client = HTTPClient()

# Raises TypeError
my_request = HTTPRequest('http://www.example.com', method='POST')
my_request.body = '{}'
http_client.fetch(my_request)
```