[Python-bugs-list] [ python-Bugs-820583 ] urllib2 silently returns None when auth_uri is mismatched

SourceForge.net noreply at sourceforge.net
Thu Oct 9 08:11:59 EDT 2003


Bugs item #820583, was opened at 2003-10-09 07:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=820583&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Christopher Armstrong (radeex)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2 silently returns None when auth_uri is mismatched

Initial Comment:
Code like the following, where the `uri' argument which
I pass to add_password is not actually the URI that the
web server gives me in its request for basic auth,
makes the return value of OpenDirector.open None. This
is either a code bug or a documentation bug. I expected
director.open to raise an error, but saying something
like "open will return None in these cases: ...." would
also be a valid solution, if one that's not as good,
IMO... the AuthHandler could raise an error once it
realizes that none of the URIs we have match, perhaps?

import urllib2

realm = "Linksys BEFW11S4 V4"

passman = urllib2.HTTPPasswordMgr()
passman.add_password(realm,
'NOT_WHAT_THE_SERVER_GIVES_ME', 'user', 'password')

auther = urllib2.HTTPBasicAuthHandler(passman)
getter = urllib2.HTTPHandler()

director = urllib2.OpenerDirector()

director.add_handler(auther)
director.add_handler(getter)


f = director.open('http://192.168.1.1/Status.htm')
print f, "is None"


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

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



More information about the Python-bugs-list mailing list