@@ -303,6 +303,8 @@ def _print_debug(self, *args):
303303 def _get_socket (self , host , port , timeout ):
304304 # This makes it simpler for SMTP_SSL to use the SMTP connect code
305305 # and just alter the socket connection bit.
306+ if timeout is not None and not timeout :
307+ raise ValueError ('Non-blocking socket (timeout=0) is not supported' )
306308 if self .debuglevel > 0 :
307309 self ._print_debug ('connect: to' , (host , port ), self .source_address )
308310 return socket .create_connection ((host , port ), timeout ,
@@ -1030,13 +1032,12 @@ def __init__(self, host='', port=0, local_hostname=None,
10301032 keyfile = keyfile )
10311033 self .context = context
10321034 SMTP .__init__ (self , host , port , local_hostname , timeout ,
1033- source_address )
1035+ source_address )
10341036
10351037 def _get_socket (self , host , port , timeout ):
10361038 if self .debuglevel > 0 :
10371039 self ._print_debug ('connect:' , (host , port ))
1038- new_socket = socket .create_connection ((host , port ), timeout ,
1039- self .source_address )
1040+ new_socket = super ()._get_socket (host , port , timeout )
10401041 new_socket = self .context .wrap_socket (new_socket ,
10411042 server_hostname = self ._host )
10421043 return new_socket
@@ -1065,15 +1066,15 @@ class LMTP(SMTP):
10651066 ehlo_msg = "lhlo"
10661067
10671068 def __init__ (self , host = '' , port = LMTP_PORT , local_hostname = None ,
1068- source_address = None ):
1069+ source_address = None ):
10691070 """Initialize a new instance."""
1070- SMTP .__init__ (self , host , port , local_hostname = local_hostname ,
1071- source_address = source_address )
1071+ super () .__init__ (host , port , local_hostname = local_hostname ,
1072+ source_address = source_address )
10721073
10731074 def connect (self , host = 'localhost' , port = 0 , source_address = None ):
10741075 """Connect to the LMTP daemon, on either a Unix or a TCP socket."""
10751076 if host [0 ] != '/' :
1076- return SMTP .connect (self , host , port , source_address = source_address )
1077+ return super () .connect (host , port , source_address = source_address )
10771078
10781079 # Handle Unix-domain sockets.
10791080 try :
0 commit comments