diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2015-06-29 10:56:51 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2015-06-29 10:56:51 +0900 |
| commit | a560e094279c755b7a9bd5f3d29c303155ed8b27 (patch) | |
| tree | e7ed9da00161f2364f9c60e87b839686474d7288 /requests/utils.py | |
| parent | f5dacf84468ab7e0631cc61a3f1431a32e3e143c (diff) | |
| download | python-requests-a560e094279c755b7a9bd5f3d29c303155ed8b27.tar.gz | |
Allow get_netrc_auth to raise parse/permission errors to caller
If the netrc file exists but cannot be parsed or read, get_netrc_auth
silently fails.
Add a new argument `ignore_errors` which when set to False will cause
any parse/permission errors to be raised to the caller. The default
value is True, which means the default behavior is unchanged.
Fixes #2654
Change-Id: I7436aaaf593178673ab84fd9e7ab4bcb0e3fe75e
Diffstat (limited to 'requests/utils.py')
| -rw-r--r-- | requests/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/requests/utils.py b/requests/utils.py index 8fba62dd..db841a36 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -67,7 +67,7 @@ def super_len(o): return len(o.getvalue()) -def get_netrc_auth(url): +def get_netrc_auth(url, ignore_errors=True): """Returns the Requests tuple auth for a given url from netrc.""" try: @@ -106,7 +106,8 @@ def get_netrc_auth(url): except (NetrcParseError, IOError): # If there was a parsing error or a permissions issue reading the file, # we'll just skip netrc auth - pass + if not ignore_errors: + raise # AppEngine hackiness. except (ImportError, AttributeError): |
