summaryrefslogtreecommitdiffstats
path: root/Lib/netrc.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-26 04:29:23 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-26 04:29:23 (GMT)
commitc12a813aa7671ee12ccb79a70177a62bcefa2561 (patch)
treef6512593e7c4ed8211f2dd2c34c8676b5ed6301e /Lib/netrc.py
parentdaa251ca097e7f7382ed57c10efbbaddad103afb (diff)
downloadcpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.zip
cpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.tar.gz
cpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.tar.bz2
Patch # 1331 by Christian Heimes.
The patch fixes some of the problems on Windows. It doesn't introduce addition problems on Linux.
Diffstat (limited to 'Lib/netrc.py')
-rw-r--r--Lib/netrc.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/netrc.py b/Lib/netrc.py
index 754828c..90255df8 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: