From: Ben Darnell Date: Wed, 21 Apr 2010 20:57:05 +0000 (-0700) Subject: cStringIO's constructor uses a 16-bit encoding when given a unicode X-Git-Tag: v1.0.0~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c87e84f068706eca9e078937c8ff5857a72b8331;p=thirdparty%2Ftornado.git cStringIO's constructor uses a 16-bit encoding when given a unicode string. This is inconsistent with its write method, which encodes all strings as ascii (and rejects unicode strings iff they have any non-ascii characters). This change uses utf-8 as the default encoding when constructing cStringIO objects in tornado. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index ac4ad985a..c8702d209 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -406,7 +406,7 @@ def _curl_setup_request(curl, request, buffer, headers): # Handle curl's cryptic options for every individual HTTP method if request.method in ("POST", "PUT"): - request_buffer = cStringIO.StringIO(request.body) + request_buffer = cStringIO.StringIO(request.body.encode('utf-8')) curl.setopt(pycurl.READFUNCTION, request_buffer.read) if request.method == "POST": def ioctl(cmd): diff --git a/tornado/wsgi.py b/tornado/wsgi.py index e3f0a50b5..07f4a2be8 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -261,7 +261,7 @@ class WSGIContainer(object): "SERVER_PROTOCOL": request.version, "wsgi.version": (1, 0), "wsgi.url_scheme": request.protocol, - "wsgi.input": cStringIO.StringIO(request.body), + "wsgi.input": cStringIO.StringIO(request.body.encode('utf-8')), "wsgi.errors": sys.stderr, "wsgi.multithread": False, "wsgi.multiprocess": True,