From: Antoine Pitrou Date: Sat, 27 Aug 2011 23:20:42 +0000 (+0200) Subject: Provide a better diagnosis on socket errors X-Git-Tag: v3.3.0a1~1608^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b2e160d279c031d714206007e22df9e177de44e;p=python Provide a better diagnosis on socket errors --- diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 7b97a6a88f..13c56e196f 100644 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -364,8 +364,10 @@ class SMTP: while 1: try: line = self.file.readline() - except socket.error: - line = '' + except socket.error as e: + self.close() + raise SMTPServerDisconnected("Connection unexpectedly closed: " + + str(e)) if not line: self.close() raise SMTPServerDisconnected("Connection unexpectedly closed")