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: Incorrect example for add_password()
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: bkline, georg.brandl, nnorwitz
Priority: normal Keywords:

Created on 2007-04-18 16:56 by bkline, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug1703110.patch bkline, 2007-04-23 01:38 Patch for source and documentation.
Messages (6)
msg31826 - (view) Author: Bob Kline (bkline) * Date: 2007-04-18 16:56
In the documentation for urllib2, the example [1] for using basic HTTP authentication has the following code for the call to add_password():

auth_handler.add_password('realm', 'host', 'username', 'password')

This actually worked in earlier (pre-2.4.3) versions of urllib2, but even in those older versions, the documentation for HTTPPasswordMgr.add_password() makes it clear that a URI must be passed as the second argument to the method, not a host name.

Even though the behavior in the library method has changed (passing a full URI versions of Python earlier than 2.4.3 didn't work, at least when a non-standard port was specified), the documentation has not changed (the add_password() documentation specifies a URI, even in the pre-2.4.3 versions of Python) and the examples in the documentation for urllib2 still say 'host'.

[1] http://docs.python.org/lib/urllib2-examples.html
msg31827 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-04-21 23:49
Bob, can you submit a patch to correct these problems?  Note:  we no longer support the 2.4 series.
msg31828 - (view) Author: Bob Kline (bkline) * Date: 2007-04-22 21:00
If I'm not right in assuming that the documentation is generated directly from urllib2.py let me know and I'll try to find the right separate file in svn.
File Added: urllib2.py.patch
msg31829 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-04-22 22:25
The docs are maintained separately, you'll have to look at Doc/lib/liburllib2.tex.
msg31830 - (view) Author: Bob Kline (bkline) * Date: 2007-04-23 01:38
File Added: bug1703110.patch
msg31831 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-04-24 04:54
Thanks for the patch!

Committed revision 54932.
Committed revision 54933. (2.5)
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44860
2007-04-18 16:56:39bklinecreate