From 6b2e160d279c031d714206007e22df9e177de44e Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sun, 28 Aug 2011 01:20:42 +0200 Subject: [PATCH] Provide a better diagnosis on socket errors --- Lib/smtplib.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 7b97a6a88ff..13c56e196f8 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")