Skip to content

Commit

Permalink
cStringIO's constructor uses a 16-bit encoding when given a unicode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ben Darnell committed Apr 21, 2010
1 parent b686d6d commit c87e84f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tornado/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tornado/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def environ(request):
"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,
Expand Down

0 comments on commit c87e84f

Please sign in to comment.