[Python-checkins] cpython (3.2): Provide a better diagnosis on socket errors

antoine.pitrou python-checkins at python.org
Sun Aug 28 01:26:54 CEST 2011


http://hg.python.org/cpython/rev/87b9399e83c7
changeset:   72106:87b9399e83c7
branch:      3.2
parent:      72103:8be834277879
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun Aug 28 01:20:42 2011 +0200
summary:
  Provide a better diagnosis on socket errors

files:
  Lib/smtplib.py |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Lib/smtplib.py b/Lib/smtplib.py
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -364,8 +364,10 @@
         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")

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list