Be less defensive in get_auth_from_url.

This commit is contained in:
Cory Benfield
2014-01-12 14:44:53 +00:00
parent b4ca6c95b6
commit 2f98ef1792
+4 -7
View File
@@ -634,14 +634,11 @@ def except_on_missing_scheme(url):
def get_auth_from_url(url):
"""Given a url with authentication components, extract them into a tuple of
username,password."""
if url:
parsed = urlparse(url)
parsed = urlparse(url)
try:
auth = (unquote(parsed.username), unquote(parsed.password))
except (AttributeError, TypeError):
auth = ('', '')
else:
try:
auth = (unquote(parsed.username), unquote(parsed.password))
except (AttributeError, TypeError):
auth = ('', '')
return auth