Skip to content

Commit c3454f0

Browse files
matrixisezhangyangyu
authored andcommitted
bpo-30394: Fix a socket leak in smtplib.SMTP.__init__() (#1700) (#1790)
1 parent 9bcf81d commit c3454f0

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
@@ -250,6 +250,7 @@ def __init__(self, host='', port=0, local_hostname=None,
250250
if host:
251251
(code, msg) = self.connect(host, port)
252252
if code != 220:
253+
self.close()
253254
raise SMTPConnectError(code, msg)
254255
if local_hostname is not None:
255256
self.local_hostname = local_hostname

0 commit comments

Comments
 (0)