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

sorin report at bugs.python.org
Sat Jun 25 21:54:24 CEST 2011


sorin <sorin.sbarnea at gmail.com> added the comment:

I have to add some details here. First, this bug has nothing to do with the URL, it does reproduce for normal urls.


Still the problem with the line: "msg += message_body" is quite complex when combined with Python 2.7:

type(msg) is unicode
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.

If I am not mistaken the code will work with Python 3.x, because there bytes() are not str().

----------

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


More information about the Python-bugs-list mailing list