diff -r a3e48273dce3 Lib/smtplib.py --- a/Lib/smtplib.py Tue Oct 18 17:16:00 2011 +0200 +++ b/Lib/smtplib.py Wed Oct 19 10:45:02 2011 +0200 @@ -276,12 +276,19 @@ class SMTP: """ self.debuglevel = debuglevel - def _get_socket(self, port, host, timeout): - # This makes it simpler for SMTP_SSL to use the SMTP connect code - # and just alter the socket connection bit. + def _get_socket(self, host, port, timeout): + """ Connect to host:port and return the socket object. + + This method simply invokes socket.create_connection, so you may wonder + why don't we just call that function instead. The reason why that is + not done is because SMTP_SSL subclasses SMTP and overrides _get_socket; + with this approach both classes use internally the same private method. + + """ + 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.