Title: Wrong order of parameters of _get_socket in SMTP class in
Type: Stage:
Components: Library (Lib) Versions: Python 2.7, Python 2.6
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: alito, georg.brandl
Priority: normal Keywords:

Created on 2010-01-14 13:15 by alito, last changed 2010-08-01 07:43 by georg.brandl. This issue is now closed.

Messages (2)
msg97761 - (view) Author: Alejandro Dubrovsky (alito) Date: 2010-01-14 13:15
Trivial change with (almost) no effect.

The method signature for _get_socket in the SMTP class in is 

def _get_socket(self, port, host, timeout)

It should be:

def _get_socket(self, host, port, timeout)

1) It calls socket.create_connection((port, host), ....) but socket.create_connection expects (host, port).
2) The only time it is called in, it is called as self._get_socket(host, port, self.timeout)
3) 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:

---	(revision 77465)
+++	(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)
+        return socket.create_connection((host, port), timeout)
     def connect(self, host='localhost', port = 0):
         """Connect to a host on a given port.
msg112276 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-01 07:43
This appears to have been fixed since r61624.
Date User Action Args
2010-08-01 07:43:37georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg112276

resolution: out of date
2010-01-14 13:15:12alitocreate