This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vsergeev
Recipients vsergeev
Date 2012-05-08.21:15:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1336511750.16.0.237606043889.issue14758@psf.upfronthosting.co.za>
In-reply-to
Content
The SMTPServer class of the smtpd module creates a server socket with the IPv4 socket.AF_INET address family hardcoded, and this prevents it from later binding to an IPv6 local address.

This occurs on line 282 of smtpd.py for the Python 2.7 branch:
http://hg.python.org/cpython/file/5319a4bf72e7/Lib/smtpd.py#l282

And on line 435 of smtpd for the Python 3.2 branch ( Lib/smtpd.py:435 ):
http://hg.python.org/cpython/file/d937b527b76e/Lib/smtpd.py#l435

One IPv4/IPv6 agnostic solution is to look up provided local address with getaddrinfo(), and use one of the result's address family, socket type and address tuple for create_socket() and bind() at those lines:

...
try:
    gai_results = socket.getaddrinfo(localaddr[0], localaddr[1])
    self.create_socket(gai_results[0][0], gai_results[0][1])
    # try to re-use a server port if possible
    self.set_reuse_addr()
    self.bind(gai_results[0][4])
    self.listen(5)
...
History
Date User Action Args
2012-05-08 21:15:50vsergeevsetrecipients: + vsergeev
2012-05-08 21:15:50vsergeevsetmessageid: <1336511750.16.0.237606043889.issue14758@psf.upfronthosting.co.za>
2012-05-08 21:15:49vsergeevlinkissue14758 messages
2012-05-08 21:15:49vsergeevcreate