[issue11281] smtplib: add ability to bind to specific source IP address/port
Giampaolo Rodola'
report at bugs.python.org
Wed Feb 23 02:49:35 CET 2011
Giampaolo Rodola' <g.rodola at gmail.com> added the comment:
Follow my comments:
> + source_address=('', 0)):
Make that default to None instead and pass it as-is to socket.create_connection().
> + self.source_address = source_address
There's no need to store the source address as an instance attribute.
Just pass it as-is to socket.create_connection() in __init__ and connect methods and then get rid of it.
I think source_address no longer makes sense in UNIX sockets / LMTP class.
Or at least, this is what I get if I try to bind() a UNIX socket:
>>> import socket
>>> sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
>>> sock.bind(("", 0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in bind
TypeError: argument must be string or read-only character buffer, not tuple
>>>
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11281>
_______________________________________
More information about the Python-bugs-list
mailing list