]> granicus.if.org Git - python/commitdiff
bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1789)
authorStéphane Wirtel <stephane@wirtel.be>
Wed, 24 May 2017 18:49:24 +0000 (20:49 +0200)
committerXiang Zhang <angwerzx@126.com>
Wed, 24 May 2017 18:49:24 +0000 (02:49 +0800)
Lib/smtplib.py

index 5b9e66536a899cce211b08520704068319edde0f..ab3197cc12dcd7c618011f7551ff5a508c3becb7 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