summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
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 6536371..77cd223 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)