From 80319a3a53dca3b816390fc87ac557d1e9e81e89 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Thu, 28 May 2009 03:10:59 +0000 Subject: explicitly close the file, merged from py3k --- Lib/netrc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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: -- cgit v0.12