[issue11898] Sending binary data with a POST request in httplib can cause Unicode exceptions

Senthil Kumaran report at bugs.python.org
Sat Jun 25 22:22:42 CEST 2011


Senthil Kumaran <senthil at uthcode.com> added the comment:

Hi Sorin,
On Sat, Jun 25, 2011 at 07:54:24PM +0000, sorin wrote:
> type(message_body) is str ... even if I tried to manually force
> Python for use bytes. It seams that in 2.7 bytes are alias to str.
> Due to this the code will fail to run only on 2.7 because it will
> try to convert  binary data to unicode string.

Bit confused here. You encode the string to bytes and decode it back
to str. One does not force bytes to str. And if you use, str or bytes
consistently in Python2.7 you wont face the problem.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11898>
_______________________________________


More information about the Python-bugs-list mailing list