kennethreitz/requests — pull request #1846 by acdha (2014-01-07 16:38:29+00:00)
Title: get_netrc_auth should handle os.path.expanduser failing

https://github.com/toastdriven/django-haystack/issues/924 has a problem report from a user who appears to be running inside a process which does not have `$HOME` defined and is running under a UID which is either not in /etc/passwd or does not have permission to access it.

This causes [utils.get_netrc_auth](https://github.com/kennethreitz/requests/blob/v2.1.0/requests/utils.py#L73) to raise an unexpected `KeyError`. The easiest fix would be to simply add that to the except block at the bottom but that's probably too dangerous – I'd probably handle the `KeyError` right at the source until this can be fixed upstream.