diff options
Diffstat (limited to 'Lib/netrc.py')
-rw-r--r-- | Lib/netrc.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/netrc.py b/Lib/netrc.py index 0fd37e304f5..c96db6f96a6 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,15 +37,13 @@ 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] == '#': - # 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() + if lexer.lineno == saved_lineno and len(tt) == 1: + lexer.instream.readline() continue elif tt == 'machine': entryname = lexer.get_token() @@ -119,4 +117,4 @@ class netrc: return rep if __name__ == '__main__': - print netrc() + print(netrc()) |