bug #1257988: don't bail out on gethostbyname(gethostname()) failure

This commit is contained in:
Georg Brandl 2006-03-31 19:34:13 +00:00
parent b88e19c1fc
commit dcdfd22bb4
1 changed files with 5 additions and 1 deletions

View File

@ -255,7 +255,11 @@ class SMTP:
self.local_hostname = fqdn
else:
# We can't find an fqdn hostname, so use a domain literal
addr = socket.gethostbyname(socket.gethostname())
addr = '127.0.0.1'
try:
addr = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
pass
self.local_hostname = '[%s]' % addr
def set_debuglevel(self, debuglevel):