Different results for different versions of urllib2

Diego Manenti Martins dmmartins at gmail.com
Fri Apr 20 23:06:11 EDT 2012


On Fri, Apr 20, 2012 at 11:09 PM, Dave Angel <d at davea.name> wrote:
> You forgot to include the list in your response.  I don't normally
> respond to private messages, but I'll make an exception.

Sorry about that and thanks.

>> 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.


> 1) Don't retype it, copy/paste it.  Far too much time is wasted finding
> bugs which were just introduced when people compose their emails by
> retyping stuff.   Post exactly what you ran.

I copied it. just changed the server name. It's the code I ran and
works on 2.6 and not on 2.7
Even don't specifying the 'rb' when open the file, that code works on python 2.6

> 2) Be specific about what behavior has you bothered.  You say it's
> "different".  From that I could conclude that in Python 2.6 it prints
> "April Fool" and in Python 2.7 it blows up your machine.

The problem is that I don't know what is wrong. I don't have access to
the server I'm sending data. I just get a server error when running
the code with python 2.7
I just wonder if someone get some behavior like this or know if
something changed on urllib2 and libs that are used on it.

Thank you for your time.

-- 
diego



More information about the Python-list mailing list