Passing a unicode object to request.write corrupts the entire response
| Newsgroups | gmane.comp.python.twisted.bugs |
|---|---|
| Message-ID | <[email protected]> |
New submission from radix <[email protected]>: 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. ---------- Type : defect Component: web Keywords : Priority : normal Nosy : ---------- http://twistedmatrix.com/trac/ticket/3896