[ python-Bugs-954981 ] Error in urllib2 Examples

SourceForge.net noreply at sourceforge.net
Tue Dec 27 00:37:12 CET 2005


Bugs item #954981, was opened at 2004-05-16 23:33
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=954981&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Phillip (phillip_)
Assigned to: Nobody/Anonymous (nobody)
Summary: Error in urllib2 Examples

Initial Comment:
I'll quote from the urllib2 examples:
>>>
Here we are sending a data-stream to the stdin of a CGI
and reading the data it returns to us:

>>> import urllib2
>>> req =
urllib2.Request(url='https://localhost/cgi-bin/test.cgi',
...                       data='This data is passed to
stdin of the CGI')
>>> f = urllib2.urlopen(req)
...
<<<

urllib2 returns:
urllib2.URLError: <urlopen error unknown url type: https>
(This is the Errormsg in 2.3.3, 2.2.3 is a different
syntax but says the same. This is seriously misleading,
as it implies that somehow urllib2 can handle https,
which it can't in this manner. At least not in the way
exampled here.

Please correct or delete this example.

It would be nice if you could provide a working example
for handling https. Examples are a good thing in the
whole httplib / urllib / urllib2 area, since it appears
somewhat hard to overlook.
I'm sorry I can't provide a working version of this
example, as I am trying to figure out how to handle
https myself.

Anyway, it's a documentation bug and needs fixing.

Thanks.

----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-12-27 00:37

Message:
Logged In: YES 
user_id=1188172

Added the note Martin suggested in rev. 41824/41825.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-06-03 11:38

Message:
Logged In: YES 
user_id=21627

What operating system are you using? The example works fine
for me, when modified to use an actual web server:

>>>
urllib2.Request("https://sourceforge.net/tracker/index.php","func=detail&aid=954981&group_id=5470&atid=105470")
<urllib2.Request instance at 0x818bf1c>
>>>
r=urllib2.Request("https://sourceforge.net/tracker/index.php","func=detail&aid=954981&group_id=5470&atid=105470")
>>> f=urllib2.urlopen(r)
>>> f.read()

Can you provide the complete traceback?

For https to work, your Python installation must support
SSL. For this, import _ssl must succeed. For that to work,
OpenSSL must have been used when Python was built.

I can add a text to the documentation indicating that the
example fails if the Python installation does not support SSL.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=954981&group_id=5470


More information about the Python-bugs-list mailing list