Be less defensive in get_auth_from_url.
authorCory Benfield <lukasaoz@gmail.com>
Sun, 12 Jan 2014 14:44:53 +0000 (14:44 +0000)
committerCory Benfield <lukasaoz@gmail.com>
Sun, 12 Jan 2014 14:44:53 +0000 (14:44 +0000)
requests/utils.py

index 528e7c9..7b7ff0a 100644 (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