Issue 4929: Handle socket errors when receiving

This commit is contained in:
Kristján Valur Jónsson 2009-01-15 17:20:21 +00:00
parent a200dd5584
commit 51a035e383
1 changed files with 4 additions and 1 deletions

View File

@ -334,7 +334,10 @@ class SMTP:
if self.file is None:
self.file = self.sock.makefile('rb')
while 1:
line = self.file.readline()
try:
line = self.file.readline()
except socket.error:
line = ''
if line == '':
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")