]> granicus.if.org Git - python/commitdiff
bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700)
authorJoel Hillacre <joel@403forbidden.ca>
Wed, 24 May 2017 05:14:50 +0000 (23:14 -0600)
committerXiang Zhang <angwerzx@126.com>
Wed, 24 May 2017 05:14:50 +0000 (13:14 +0800)
Lib/smtplib.py

index f7c2c77ab42075b7ba75fe74cbcf7f51324ff7dd..5e422b704ad4dc6566998d629fa2ba5c225e65d5 100755 (executable)
@@ -250,6 +250,7 @@ class SMTP:
         if host:
             (code, msg) = self.connect(host, port)
             if code != 220:
+                self.close()
                 raise SMTPConnectError(code, msg)
         if local_hostname is not None:
             self.local_hostname = local_hostname