This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error in urllib2 Examples
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, loewis, phillip_
Priority: normal Keywords:

Created on 2004-05-16 21:33 by phillip_, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20817 - (view) Author: Phillip (phillip_) Date: 2004-05-16 21:33
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.
msg20818 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-06-03 09:38
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.
msg20819 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-26 23:37
Logged In: YES 
user_id=1188172

Added the note Martin suggested in rev. 41824/41825.
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40261
2004-05-16 21:33:15phillip_create