From: Senthil Kumaran Date: Tue, 3 Jun 2014 14:24:54 +0000 (-0700) Subject: Fix issue #21641: Close the socket before raising the SMTPResponseException. Fixes... X-Git-Tag: v3.4.2rc1~452 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ce118e99a21639ceed744ced7d35d8f0ec5f0c2;p=python Fix issue #21641: Close the socket before raising the SMTPResponseException. Fixes the ResourceWarning in the test run. Patch by Claudiu.Popa. --- 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]