summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-03-31 19:34:13 (GMT)
committerGeorg Brandl <georg@python.org>2006-03-31 19:34:13 (GMT)
commitdcdfd22bb411ebf0d58bba135455c4abf2bc9ce1 (patch)
treed0d8d1beb7c46deffdf34a481fbe1f2a25ff94d1 /Lib
parentb88e19c1fc182a97b961633c29f485c2de6ad525 (diff)
downloadcpython-dcdfd22bb411ebf0d58bba135455c4abf2bc9ce1.zip
cpython-dcdfd22bb411ebf0d58bba135455c4abf2bc9ce1.tar.gz
cpython-dcdfd22bb411ebf0d58bba135455c4abf2bc9ce1.tar.bz2
bug #1257988: don't bail out on gethostbyname(gethostname()) failure
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/smtplib.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 71d25fd..07916cc 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -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):