]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport akuchling's checkin of
authorMichael W. Hudson <mwh@python.net>
Mon, 25 Mar 2002 13:22:14 +0000 (13:22 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 25 Mar 2002 13:22:14 +0000 (13:22 +0000)
    revision 1.14 of netrc.py

[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.

Lib/netrc.py

index 3f1c7c3c4c73c19bcfa2b3f37e4c437704f36103..294399d35b0b98b97d70f1c17807b3ff1755bfdf 100644 (file)
@@ -41,28 +41,26 @@ class netrc:
             elif tt == 'macdef':                # Just skip to end of macdefs
                 entryname = lexer.get_token()
                 self.macros[entryname] = []
-                lexer.whitepace = ' \t'
+                lexer.whitespace = ' \t'
                 while 1:
                     line = lexer.instream.readline()
-                    if not line or line == '\012' and tt == '\012':
-                        lexer.whitepace = ' \t\r\n'
+                    if not line or line == '\012':
+                        lexer.whitespace = ' \t\r\n'
                         break
-                    tt = line
                     self.macros[entryname].append(line)
+                continue
             else:
                 raise NetrcParseError(
                     "bad toplevel token %r" % tt, file, lexer.lineno)
 
             # We're looking at start of an entry for a named machine or default.
-            if toplevel == 'machine':
-                login = account = password = None
-                self.hosts[entryname] = {}
+            login = account = password = None
+            self.hosts[entryname] = {}
             while 1:
                 tt = lexer.get_token()
-                if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef':
-                    if toplevel == 'macdef':
-                        break
-                    elif login and password:
+                if (tt=='' or tt == 'machine' or
+                    tt == 'default' or tt =='macdef'):
+                    if login and password:
                         self.hosts[entryname] = (login, account, password)
                         lexer.push_token(tt)
                         break