Commit 068db13e authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

[Bug #532115] netrc module was broken

   * 'macdef' (macro definition) wasn't parsed correctly
   * account value not reset for a subsequent 'default' line
   * typo: 'whitepace' -> 'whitespace'

Bugfix candidate.
parent e8f2230c
...@@ -44,28 +44,26 @@ class netrc: ...@@ -44,28 +44,26 @@ class netrc:
elif tt == 'macdef': # Just skip to end of macdefs elif tt == 'macdef': # Just skip to end of macdefs
entryname = lexer.get_token() entryname = lexer.get_token()
self.macros[entryname] = [] self.macros[entryname] = []
lexer.whitepace = ' \t' lexer.whitespace = ' \t'
while 1: while 1:
line = lexer.instream.readline() line = lexer.instream.readline()
if not line or line == '\012' and tt == '\012': if not line or line == '\012':
lexer.whitepace = ' \t\r\n' lexer.whitespace = ' \t\r\n'
break break
tt = line
self.macros[entryname].append(line) self.macros[entryname].append(line)
continue
else: else:
raise NetrcParseError( raise NetrcParseError(
"bad toplevel token %r" % tt, file, lexer.lineno) "bad toplevel token %r" % tt, file, lexer.lineno)
# We're looking at start of an entry for a named machine or default. # We're looking at start of an entry for a named machine or default.
if toplevel == 'machine': login = account = password = None
login = account = password = None self.hosts[entryname] = {}
self.hosts[entryname] = {}
while 1: while 1:
tt = lexer.get_token() tt = lexer.get_token()
if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if (tt=='' or tt == 'machine' or
if toplevel == 'macdef': tt == 'default' or tt =='macdef'):
break if login and password:
elif login and password:
self.hosts[entryname] = (login, account, password) self.hosts[entryname] = (login, account, password)
lexer.push_token(tt) lexer.push_token(tt)
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment