From b0e18650735dc667f76f6aff108877f03b729c23 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 20 Feb 2012 15:43:45 -0500 Subject: [PATCH] netrc fix --- requests/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/requests/utils.py b/requests/utils.py index c9f5ad7..dd93b05 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -46,8 +46,10 @@ def get_netrc_auth(url): try: _netrc = netrc(netrc_path).authenticators(host) - # Return with login / password - return (_netrc[0 if _netrc[0] else 1], _netrc[2]) + if _netrc: + # Return with login / password + login_i = (0 if _netrc[0] else 1) + return (_netrc[login_i], _netrc[2]) except NetrcParseError: pass -- 2.7.4