summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-12-14 20:34:20 (GMT)
committerBarry Warsaw <barry@python.org>2001-12-14 20:34:20 (GMT)
commit7675097d78999b7087a487b479b388ef7a7aa91e (patch)
tree385762d4613d52fb6f495f1e9ff78dc69048f9ec /Lib/smtplib.py
parent19554f60c29fbea536efd906d96f00964c37ec01 (diff)
downloadcpython-7675097d78999b7087a487b479b388ef7a7aa91e.zip
cpython-7675097d78999b7087a487b479b388ef7a7aa91e.tar.gz
cpython-7675097d78999b7087a487b479b388ef7a7aa91e.tar.bz2
send(), ehlo(): Integrate patch #487310 by Fazal Majid. Consistently
call self.close() just before raising SMTPServerDisconnected. This allows you to, e.g. reconnect after a server timeout. Merged from the 2.2c1 branch.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index d8b18e9..cb15de2 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -294,6 +294,7 @@ class SMTP:
while sendptr < len(str):
sendptr = sendptr + self.sock.send(str[sendptr:])
except socket.error:
+ self.close()
raise SMTPServerDisconnected('Server not connected')
else:
raise SMTPServerDisconnected('please run connect() first')
@@ -380,6 +381,7 @@ class SMTP:
# MTA's will disconnect on an ehlo. Toss an exception if
# that happens -ddm
if code == -1 and len(msg) == 0:
+ self.close()
raise SMTPServerDisconnected("Server not connected")
self.ehlo_resp=msg
if code != 250: