[Patches] [ python-Patches-1257988 ] fix smtplib when local host isn't resolvable in dns
SourceForge.net
noreply at sourceforge.net
Fri Mar 31 20:40:08 CEST 2006
Patches item #1257988, was opened at 2005-08-12 22:18
Message generated for change (Comment added) made by arekm
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1257988&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Arkadiusz Miskiewicz (arekm)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix smtplib when local host isn't resolvable in dns
Initial Comment:
Suppose that hostname gives hostX. hostX doesn't exists in dns nor in /
etc/hosts (it's unresolvable).
Now when trying to connect to smtp service:
>>> import smtplib
>>> smtplib.SMTP('akcyza.pld-linux.org')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/share/python2.4/smtplib.py", line 255, in __init__
socket.gaierror: (-2, 'Name or service not known')
The problem is gethostbyname() here:
# We can't find an fqdn hostname, so use a domain literal
addr = socket.gethostbyname(socket.gethostname())
self.local_hostname = '[%s]' % addr
It's much easier and better to just use getsockname() for local socket.
Attached patch fixes this problem and doesn't require for the local
system to be resolvable in dns/hosts.
----------------------------------------------------------------------
>Comment By: Arkadiusz Miskiewicz (arekm)
Date: 2006-03-31 20:40
Message:
Logged In: YES
user_id=139606
Patch is wrong btw. Doesn't allow to create pure object
without connecting.
----------------------------------------------------------------------
Comment By: Arkadiusz Miskiewicz (arekm)
Date: 2005-08-24 19:00
Message:
Logged In: YES
user_id=139606
On unconnected socket it returns 0.0.0.0 afaik which doesn't happen
here. Please drop that part.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2005-08-24 17:01
Message:
Logged In: YES
user_id=21627
Why would getsockname return '0.0.0.0'?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1257988&group_id=5470
More information about the Patches
mailing list