Issue 7702: Wrong order of parameters of _get_socket in SMTP class in smtplib.py (original) (raw)
Trivial change with (almost) no effect.
The method signature for _get_socket in the SMTP class in stmplib.py is
def _get_socket(self, port, host, timeout)
It should be:
def _get_socket(self, host, port, timeout)
Evidence:
- It calls socket.create_connection((port, host), ....) but socket.create_connection expects (host, port).
- The only time it is called in smtplib.py, it is called as self._get_socket(host, port, self.timeout)
- In the derived class SMTP_SSL, it is defined as (self, host, port, timeout)
I wrote almost no effect because the debugging output from it will now be in the right order (host, port).
Patch wrt python svn trunk follows:
Index: smtplib.py
--- smtplib.py (revision 77465) +++ smtplib.py (working copy) @@ -266,11 +266,11 @@ """ self.debuglevel = debuglevel
- def _get_socket(self, port, host, timeout):
- def _get_socket(self, host, port, timeout): # This makes it simpler for SMTP_SSL to use the SMTP connect code # and just alter the socket connection bit. if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
return socket.create_connection((port, host), timeout)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.return socket.create_connection((host, port), timeout)