]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 1.18:
authorRaymond Hettinger <python@rcn.com>
Fri, 25 Apr 2003 04:37:40 +0000 (04:37 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Apr 2003 04:37:40 +0000 (04:37 +0000)
SF bug 557704: netrc module can't handle all passwords

Let netrc handle entries with login fields (mail servers for instance)
by having login default to ''.

Lib/netrc.py

index 5c9e1ff5217f79b1be9a6b971725da6408bb5a60..3290b1795c49005bfbf4a9f1554eeeb4baa62890 100644 (file)
@@ -27,7 +27,7 @@ class netrc:
         self.hosts = {}
         self.macros = {}
         lexer = shlex.shlex(fp)
-        lexer.wordchars  += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
+        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
         while 1:
             # Look for a machine, default, or macdef top-level keyword
             toplevel = tt = lexer.get_token()
@@ -53,13 +53,14 @@ class netrc:
                     "bad toplevel token %r" % tt, file, lexer.lineno)
 
             # We're looking at start of an entry for a named machine or default.
-            login = account = password = None
+            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 login and password:
+                    if password:
                         self.hosts[entryname] = (login, account, password)
                         lexer.push_token(tt)
                         break