summaryrefslogtreecommitdiffstats
path: root/Lib/netrc.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-06-10 17:29:40 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-06-10 17:29:40 (GMT)
commit9aa68e4b324d4c130338bceabd8ccc058bf24231 (patch)
tree0131a1ec84591c4a940fcfed8478438a811311b3 /Lib/netrc.py
parenta13660807eec3476bb527061d0130aa700a96908 (diff)
parent1df0f214a9fdb4dde7506576b144cf6a7fd01b65 (diff)
downloadcpython-9aa68e4b324d4c130338bceabd8ccc058bf24231.zip
cpython-9aa68e4b324d4c130338bceabd8ccc058bf24231.tar.gz
cpython-9aa68e4b324d4c130338bceabd8ccc058bf24231.tar.bz2
merge 3.1 (#12009)
Diffstat (limited to 'Lib/netrc.py')
-rw-r--r--Lib/netrc.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/netrc.py b/Lib/netrc.py
index a60b8b7..c96db6f 100644
--- a/Lib/netrc.py
+++ b/Lib/netrc.py
@@ -2,7 +2,7 @@
# Module and documentation by Eric S. Raymond, 21 Dec 1998
-import os, shlex
+import io, os, shlex
__all__ = ["netrc", "NetrcParseError"]
@@ -37,12 +37,14 @@ class netrc:
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
+ saved_lineno = lexer.lineno
toplevel = tt = lexer.get_token()
if not tt:
break
elif tt[0] == '#':
- fp.readline();
- continue;
+ if lexer.lineno == saved_lineno and len(tt) == 1:
+ lexer.instream.readline()
+ continue
elif tt == 'machine':
entryname = lexer.get_token()
elif tt == 'default':
@@ -68,8 +70,8 @@ class netrc:
self.hosts[entryname] = {}
while 1:
tt = lexer.get_token()
- if (tt=='' or tt == 'machine' or
- tt == 'default' or tt =='macdef'):
+ if (tt.startswith('#') or
+ tt in {'', 'machine', 'default', 'macdef'}):
if password:
self.hosts[entryname] = (login, account, password)
lexer.push_token(tt)