Fwd: Re: Different results for different versions of urllib2

Dave Angel d at davea.name
Fri Apr 20 22:09:54 EDT 2012


You forgot to include the list in your response.  I don't normally
respond to private messages, but I'll make an exception.


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')
>
>
>
-------- Original Message --------
Subject: Re: Different results for different versions of urllib2
Date: Fri, 20 Apr 2012 22:27:05 -0300
From: Diego Manenti Martins <dmmartins at gmail.com>
To: d at davea.name

Well it's not on urllib2 file.
I just switched it from a 2.6 urllib2.py and same result..


And by top-posting, you messed up the sequence.  I pasted it to the
proper place, but of course it's not formatted right.

Anyway, I can't help you with the urlib2-specific portion of your
problem. I could give you some advice on how to get quality responses,
though.

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.

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.

--
DaveA



More information about the Python-list mailing list