diff -r 5673cf852daa Lib/netrc.py --- a/Lib/netrc.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/netrc.py Sat Oct 01 17:30:27 2016 +0200 @@ -23,10 +23,7 @@ def __init__(self, file=None): default_netrc = file is None if file is None: - try: - file = os.path.join(os.environ['HOME'], ".netrc") - except KeyError: - raise OSError("Could not find .netrc: $HOME is not set") + file = os.path.expanduser("~/.netrc") self.hosts = {} self.macros = {} with open(file) as fp: