diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-06-10 16:33:41 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-06-10 16:33:41 (GMT) |
| commit | 8b8162d868114bd47d176c6c49c51a5d54d41e12 (patch) | |
| tree | 5e6980cd53df6bad0ed95834f4bc9e5d3d32a3dd /Lib/netrc.py | |
| parent | ce5493f33d75de2861ccadc618f6f250ab11d2f4 (diff) | |
| parent | 43ee1a5d90df3181628fe03c67254aef1bb93f04 (diff) | |
| download | cpython-8b8162d868114bd47d176c6c49c51a5d54d41e12.zip cpython-8b8162d868114bd47d176c6c49c51a5d54d41e12.tar.gz cpython-8b8162d868114bd47d176c6c49c51a5d54d41e12.tar.bz2 | |
merge 2.7.2 release branch with fix for #12009
Diffstat (limited to 'Lib/netrc.py')
| -rw-r--r-- | Lib/netrc.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/netrc.py b/Lib/netrc.py index 4caeb96..0fd37e3 100644 --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -41,8 +41,12 @@ class netrc: if not tt: break elif tt[0] == '#': - fp.readline(); - continue; + # seek to beginning of comment, in case reading the token put + # us on a new line, and then skip the rest of the line. + pos = len(tt) + 1 + lexer.instream.seek(-pos, 1) + lexer.instream.readline() + continue elif tt == 'machine': entryname = lexer.get_token() elif tt == 'default': @@ -68,8 +72,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) |
