SMTP.connect(): If the socket.connect() raises a socket.error, be sure

to call self.close() to reclaim some file descriptors, the reraise the
exception.  Closes SF patch #102185 and SF bug #119833.
This commit is contained in:
Barry Warsaw 2000-11-08 22:19:47 +00:00
parent 8a41d20b05
commit 17bfef5860
1 changed files with 5 additions and 1 deletions

View File

@ -214,7 +214,11 @@ class SMTP:
if not port: port = SMTP_PORT
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.debuglevel > 0: print 'connect:', (host, port)
try:
self.sock.connect((host, port))
except socket.error:
self.close()
raise
(code,msg)=self.getreply()
if self.debuglevel >0 : print "connect:", msg
return (code,msg)