]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bug #1257988: don't bail out on gethostbyname(gethostname()) failure
authorGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 19:34:13 +0000 (19:34 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 19:34:13 +0000 (19:34 +0000)
Lib/smtplib.py

index 71d25fda268ecc8916171003895c1e7e76693aad..07916cc1b80d0e1ab3e5704fb6da8f9598125ec9 100755 (executable)
@@ -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):