Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 366a1df

Browse files
committed
[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.
1 parent 83d042d commit 366a1df

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

Lib/netrc.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,26 @@ def __init__(self, file=None):
4444
elif tt == 'macdef': # Just skip to end of macdefs
4545
entryname = lexer.get_token()
4646
self.macros[entryname] = []
47-
lexer.whitepace = ' \t'
47+
lexer.whitespace = ' \t'
4848
while 1:
4949
line = lexer.instream.readline()
50-
if not line or line == '\012' and tt == '\012':
51-
lexer.whitepace = ' \t\r\n'
50+
if not line or line == '\012':
51+
lexer.whitespace = ' \t\r\n'
5252
break
53-
tt = line
5453
self.macros[entryname].append(line)
54+
continue
5555
else:
5656
raise NetrcParseError(
5757
"bad toplevel token %r" % tt, file, lexer.lineno)
5858

5959
# We're looking at start of an entry for a named machine or default.
60-
if toplevel == 'machine':
61-
login = account = password = None
62-
self.hosts[entryname] = {}
60+
login = account = password = None
61+
self.hosts[entryname] = {}
6362
while 1:
6463
tt = lexer.get_token()
65-
if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef':
66-
if toplevel == 'macdef':
67-
break
68-
elif login and password:
64+
if (tt=='' or tt == 'machine' or
65+
tt == 'default' or tt =='macdef'):
66+
if login and password:
6967
self.hosts[entryname] = (login, account, password)
7068
lexer.push_token(tt)
7169
break

0 commit comments

Comments
 (0)