diff options
author | Philip Jenvey <pjenvey@underboss.org> | 2009-05-28 03:10:59 +0000 |
---|---|---|
committer | Philip Jenvey <pjenvey@underboss.org> | 2009-05-28 03:10:59 +0000 |
commit | 648a7061b9fe1b0e5f879289c6845a80a88ffb81 (patch) | |
tree | 42e9c96a49067b732c3e7ebc37a98ffd8c9b7189 /Lib/netrc.py | |
parent | dfa4a402da6a0cc9fed306e38c7b2b7335316c74 (diff) | |
download | cpython-648a7061b9fe1b0e5f879289c6845a80a88ffb81.tar.gz |
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 5493d77d3e..723fc31d86 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: |