Ticket #3896 defect closed fixed
Passing a unicode object to request.write corrupts the entire response
Description
I passed a unicode object to request.write, and my HTTP response came out like this:
'H\x00\x00\x00T\x00\x00\x00T\x00\x00\x00P\x00\x00\x00/\x00\x00\x001\x00\x00\x00.\x00\x00\x001\x00\x00\x00'
and so on. (That's the string "HTTP/1.1" encoded in, apparently, UCS-4).
idnar points out that this may be because of cStringIO usage:
<idnar> >>> StringIO(u'abc').getvalue() <idnar> 'a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00'
In my opinion, either an exception should be immediately raised when unicode is passed to request.write, or the data should be encoded with the response's encoding, if one has been set.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

