summaryrefslogtreecommitdiff
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2000-11-08 22:19:47 +0000
committerBarry Warsaw <barry@python.org>2000-11-08 22:19:47 +0000
commite5c3bdd7d0be77889f2f6d2f32cd653f62a13e5d (patch)
treeca3c5d42be2e36160233aea2f38ae6e1ada2d413 /Lib/smtplib.py
parent8fbd9ceb6c70e4a1182f99359976d7d8ff2eb946 (diff)
downloadcpython-e5c3bdd7d0be77889f2f6d2f32cd653f62a13e5d.tar.gz
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.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 6536371846..77cd22304c 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -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)
- self.sock.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)