Bug in Python DNS module

Erik de Castro Lopo nospam at mega-nerd.net
Mon Jul 16 17:03:16 EDT 2001


A couple of days ago I asked for and received a link to a Python DNS
module. I have since found a bug in the ParseResolvConf() functions.

This is how it was:

def ParseResolvConf():
    "parses the /etc/resolv.conf file and sets defaults for name servers"
    import string
    global defaults
    lines=open("/etc/resolv.conf").readlines()
    for line in lines:
	string.strip(line)
	if line[0]==';' or line[0]=='#':
	    continue

This is how it should be:

def ParseResolvConf():
    "parses the /etc/resolv.conf file and sets defaults for name servers"
    import string
    global defaults
    lines=open("/etc/resolv.conf").readlines()
    for line in lines:
	line = string.strip(line)
	if not line or line[0]==';' or line[0]=='#':
	    continue

I'm not sure who to send it to so I'm posting it here.

Regards,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo     nospam at mega-nerd.com      (Yes its valid)
-----------------------------------------------------------------
"UNIX was not designed to stop you from doing stupid things,  because
that would also stop you from doing clever things."  -- Doug Gwyn



More information about the Python-list mailing list