From: Bob Halley Date: Thu, 17 Aug 2006 07:03:27 +0000 (+0000) Subject: if /etc/resolv.conf does not exist, just use the default resolver config X-Git-Tag: v1.5.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9383f4ca59ea88da50297bb3142f19f0ea55fd49;p=thirdparty%2Fdnspython.git if /etc/resolv.conf does not exist, just use the default resolver config --- diff --git a/ChangeLog b/ChangeLog index 41486aaf..25512f64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-17 Bob Halley + + * dns/resolver.py (Resolver.read_resolv_conf): If /etc/resolv.conf + doesn't exist, just use the default resolver configuration (i.e. + the same thing we would have used if resolv.conf had existed and + been empty). + 2006-07-26 Bob Halley * dns/resolver.py (Resolver._config_win32_fromkey): fix diff --git a/dns/resolver.py b/dns/resolver.py index 28916034..43719b71 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -317,7 +317,13 @@ class Resolver(object): a string, it is used as the name of the file to open; otherwise it is treated as the file itself.""" if isinstance(f, str) or isinstance(f, unicode): - f = open(f, 'r') + try: + f = open(f, 'r') + except IOError: + # /etc/resolv.conf doesn't exist, can't be read, etc. + # We'll just use the default resolver configuration. + self.nameservers = ['127.0.0.1'] + return want_close = True else: want_close = False