From 2f98ef17924d296a4871d909e43f5e7e365d05a3 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sun, 12 Jan 2014 14:44:53 +0000 Subject: [PATCH] Be less defensive in get_auth_from_url. --- requests/utils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/requests/utils.py b/requests/utils.py index 528e7c9..7b7ff0a 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -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 -- 2.34.1