[issue11898] Sending binary data with a POST request in httplib can cause Unicode exceptions
Jiri Horky
report at bugs.python.org
Sun May 15 20:30:00 CEST 2011
Jiri Horky <jiri.horky at gmail.com> added the comment:
I have the same problem as the original submitter.
The reason it previously worked for you was probably because you didn't utilize a "right" unicode string in the urllib2.request. The following code will raise the exception (I enclose the data file for completeness, but it fails with basically any binary data).
It works fine with Python 2.6.6, but fails with Python 2.7.1.
{{{
import urllib2
f = open("data", "r")
mydata = f.read()
f.close()
#this fails
url=unicode('http://localhost/test')
#this works
#url=str('http://localhost/test')
#this also works
#url=unicode('http://localhost')
req = urllib2.Request(url, data=mydata)
urllib2.urlopen(req)
}}}
----------
nosy: +Jiri.Horky
Added file: http://bugs.python.org/file22004/data
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11898>
_______________________________________
More information about the Python-bugs-list
mailing list