From: Stéphane Wirtel Date: Wed, 24 May 2017 18:59:06 +0000 (+0200) Subject: bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1790) X-Git-Tag: v3.6.2rc1~127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3454f0e79b35fb81b0426cfac4b801d4495b8ea;p=python bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1790) --- diff --git a/Lib/smtplib.py b/Lib/smtplib.py index f7c2c77ab4..5e422b704a 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -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