diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-05-28 03:10:59 (GMT) |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-05-28 03:10:59 (GMT) |
commit | 80319a3a53dca3b816390fc87ac557d1e9e81e89 (patch) | |
tree | 7c1f1e49e28166cf120f529a8a7eb9e768c61fa9 /Lib/netrc.py | |
parent | 1075c9b43157520a17c3afdd4e68b0e75d04b55f (diff) | |
download | cpython-80319a3a53dca3b816390fc87ac557d1e9e81e89.zip cpython-80319a3a53dca3b816390fc87ac557d1e9e81e89.tar.gz cpython-80319a3a53dca3b816390fc87ac557d1e9e81e89.tar.bz2 |
explicitly close the file, merged from py3k
Diffstat (limited to 'Lib/netrc.py')
-rw-r--r-- | Lib/netrc.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/netrc.py b/Lib/netrc.py index 5493d77..723fc31 100644 --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -26,9 +26,12 @@ class netrc: file = os.path.join(os.environ['HOME'], ".netrc") except KeyError: raise IOError("Could not find .netrc: $HOME is not set") - fp = open(file) self.hosts = {} self.macros = {} + with open(file) as fp: + self._parse(file, fp) + + def _parse(self, file, fp): lexer = shlex.shlex(fp) lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" while 1: |