From 9e98cd0383d9e7f06c0537038a32459bf5efa97a Mon Sep 17 00:00:00 2001 From: Joel Hillacre Date: Tue, 23 May 2017 23:14:50 -0600 Subject: [PATCH] bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) --- Lib/smtplib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index f7c2c77ab42..5e422b704ad 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -250,6 +250,7 @@ def __init__(self, host='', port=0, local_hostname=None, 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