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

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


http://hg.python.org/cpython/rev/a355731f105c
changeset:   72105:a355731f105c
branch:      2.7
parent:      72098:6d3c645fa52f
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun Aug 28 01:18:31 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
@@ -352,8 +352,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 line == '':
                 self.close()
                 raise SMTPServerDisconnected("Connection unexpectedly closed")

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


More information about the Python-checkins mailing list