[Python-bugs-list] netrc.py rejects hostnames (PR#243)

lannert@uni-duesseldorf.de lannert@uni-duesseldorf.de
Tue, 21 Mar 2000 19:07:53 -0500 (EST)


Hi,

I tried to use netrc.py but it chokes on my ~/.netrc: hostnames of the
form spam.uni-duesseldorf.de are rejected because of the '-' character.

The following patch against the CVS version made this module work (for
me!):

--- netrc.py~   Wed Mar 22 01:01:33 2000
+++ netrc.py    Wed Mar 22 01:02:01 2000
@@ -15,7 +15,7 @@
         self.hosts = {}
         self.macros = {}
         lexer = shlex.shlex(fp)
-        lexer.wordchars = lexer.wordchars + '.'
+        lexer.wordchars = lexer.wordchars + '.-'
         while 1:
             # Look for a machine, default, or macdef top-level keyword
             toplevel = tt = lexer.get_token()


AFAIK, '-' is a legitimate hostname character; I don't think that this
extended acceptance of the lexer could break anything else.

BTW, the following lines:

31:                lexer.whitepace = ' \t'
35:                        lexer.whitepace = ' \t\r\n'

look a bit strange; shouldn't it be "whitespace" as defined in shlex?
(But then, how did this ever work? :)

  Detlef