Provide a better diagnosis on socket errors

This commit is contained in:
Antoine Pitrou 2011-08-28 01:18:31 +02:00
parent 0f697b300c
commit 0ad7358c2f
1 changed files with 4 additions and 2 deletions

View File

@ -352,8 +352,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 line == '':
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")