From 4ce118e99a21639ceed744ced7d35d8f0ec5f0c2 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Tue, 3 Jun 2014 07:24:54 -0700 Subject: [PATCH] Fix issue #21641: Close the socket before raising the SMTPResponseException. Fixes the ResourceWarning in the test run. Patch by Claudiu.Popa. --- Lib/smtplib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index ec43666df3..759b77e47f 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -377,6 +377,7 @@ class SMTP: if self.debuglevel > 0: print('reply:', repr(line), file=stderr) if len(line) > _MAXLINE: + self.close() raise SMTPResponseException(500, "Line too long.") resp.append(line[4:].strip(b' \t\r\n')) code = line[:3] -- 2.40.0