]> granicus.if.org Git - python/commitdiff
bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1790)
authorStéphane Wirtel <stephane@wirtel.be>
Wed, 24 May 2017 18:59:06 +0000 (20:59 +0200)
committerXiang Zhang <angwerzx@126.com>
Wed, 24 May 2017 18:59:06 +0000 (02:59 +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