Skip to content

Commit 779e7c9

Browse files
matrixisezhangyangyu
authored andcommitted
bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1788)
1 parent 9395ca4 commit 779e7c9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Lib/smtplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def __init__(self, host='', port=0, local_hostname=None,
255255
if host:
256256
(code, msg) = self.connect(host, port)
257257
if code != 220:
258+
self.close()
258259
raise SMTPConnectError(code, msg)
259260
if local_hostname is not None:
260261
self.local_hostname = local_hostname

0 commit comments

Comments
 (0)