Different results for different versions of urllib2

Diego Manenti Martins dmmartins at gmail.com
Fri Apr 20 21:24:37 EDT 2012


On Fri, Apr 20, 2012 at 10:08 PM, Dave Angel <d at davea.name> wrote:
> On 04/20/2012 06:47 PM, Diego Manenti Martins wrote:
>> Hi.
>> Anybody knows the data is sent in a different way for Python 2.5, 2.6
>> and 2.7 using this code:
>>
>>>>> import urllib2
>>>>> url = 'http://server.com/post_image?tid=zoV6LJ'
>>>>> f = open('test.jpg')
>>>>> data = f.read()
>>>>> res = urllib2.urlopen(url, data)
>> It works the same way for python2.5 and python2.6 but not for python2.7
>>
>> I checked the sent data with WireShark and it sends the data in a
>> different way. I'm not an expert I just see it's different :)
>> It might be a server problem although I think the lib should behave
>> equals for all versions.
>>
>> Thoughts?
>> Thank you all!
> I'd be surprised it works at all.  A jpeg is binary, so you should be
> using the following form:
>
>    f = open('test.jpg', 'rb')

ok. I just forget it when writing the email, but get the same result.

-- 
diego



More information about the Python-list mailing list