Skip to content

Commit 4ce118e

Browse files
committed
Fix issue #21641: Close the socket before raising the SMTPResponseException. Fixes the ResourceWarning in the test run.
Patch by Claudiu.Popa.
1 parent 8dc3df1 commit 4ce118e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Lib/smtplib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ def getreply(self):
377377
if self.debuglevel > 0:
378378
print('reply:', repr(line), file=stderr)
379379
if len(line) > _MAXLINE:
380+
self.close()
380381
raise SMTPResponseException(500, "Line too long.")
381382
resp.append(line[4:].strip(b' \t\r\n'))
382383
code = line[:3]

0 commit comments

Comments
 (0)