[ python-Bugs-913698 ] smtplib : module bug with unresolved hostname
SourceForge.net
noreply at sourceforge.net
Mon Mar 15 09:54:36 EST 2004
Bugs item #913698, was opened at 2004-03-10 21:49
Message generated for change (Settings changed) made by chaica
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=913698&group_id=5470
Category: Extension Modules
Group: Python 2.3
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Zarro (chaica)
Assigned to: Nobody/Anonymous (nobody)
Summary: smtplib : module bug with unresolved hostname
Initial Comment:
I checked in the last cvs and the bug wasn't corriged.
if your hostname can't be resolved, so the module will
panic and raise a socket.gaierror in line 254:
addr = socket.gethostbyname(socket.gethostname())
>>> import socket
>>> socket.gethostname()
'desktop'
>>> socket.gethostbyname(socket.gethostname())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.gaierror: (-2, 'Name or service not known')
To correct, catch the exception and give a generic
value for self.local_hostname, for example localhost
127.0.0.1
try:
addr = socket.gethostbyname(socket.gethostname())
self.local_hostname = '[%s]' % addr
except socket.gaierror, msg:
self.local_hostname = '[%s]' % '127.0.0.1'
Keep me tuned,
chaica at ohmytux.com
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=913698&group_id=5470
More information about the Python-bugs-list
mailing list