]> 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:17 +0000 (19:34 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 31 Mar 2006 19:34:17 +0000 (19:34 +0000)
 (backport from rev. 43499)

Lib/smtplib.py

index 01ef53f0007bc8e50ba23a69b9d3de9188203702..89548809d34b063dad40e78e3f5c03f07ae41470 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):