From: Barry Warsaw Date: Fri, 14 Dec 2001 20:34:20 +0000 (+0000) Subject: send(), ehlo(): Integrate patch #487310 by Fazal Majid. Consistently X-Git-Tag: v2.2.1c1~361 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7675097d78999b7087a487b479b388ef7a7aa91e;p=python 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. --- diff --git a/Lib/smtplib.py b/Lib/smtplib.py index d8b18e9676..cb15de202f 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: