]> granicus.if.org Git - python/commitdiff
send(), ehlo(): Integrate patch #487310 by Fazal Majid. Consistently
authorBarry Warsaw <barry@python.org>
Fri, 14 Dec 2001 20:34:20 +0000 (20:34 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 14 Dec 2001 20:34:20 +0000 (20:34 +0000)
call self.close() just before raising SMTPServerDisconnected.  This
allows you to, e.g. reconnect after a server timeout.

Merged from the 2.2c1 branch.

Lib/smtplib.py

index d8b18e9676d936b77caac965cdb0a3731ab94281..cb15de202f077a9c0dfaf8730a83d0c4cd296c3a 100755 (executable)
@@ -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: