mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
explicitly close the file, merged from py3k
This commit is contained in:
parent
1075c9b431
commit
80319a3a53
1 changed files with 4 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue