Don't bonk if .netrc isn't readable.
authorBen <benweatherman@gmail.com>
Tue, 21 Feb 2012 21:53:33 +0000 (15:53 -0600)
committerBen <benweatherman@gmail.com>
Tue, 21 Feb 2012 21:53:33 +0000 (15:53 -0600)
It's possible in some shared hosting environments that the .netrc file isn't readable by the user for the calling process. In that circumstance, just forgo the netrc authentication.

requests/utils.py

index 68efa4697aa38b99eecab358aa7114dcc04c845f..106c7d8932e5c32163680b16c82d200628b3a506 100644 (file)
@@ -50,7 +50,9 @@ def get_netrc_auth(url):
             # Return with login / password
             login_i = (0 if _netrc[0] else 1)
             return (_netrc[login_i], _netrc[2])
-    except NetrcParseError:
+    except NetrcParseError, IOError:
+        # If there was a parsing error or a permissions issue reading the file,
+        # we'll just skip netrc auth
         pass