Index: Lib/imaplib.py =================================================================== --- Lib/imaplib.py (revision 75166) +++ Lib/imaplib.py (working copy) @@ -1001,6 +1001,8 @@ raise self.abort('socket error: EOF') # Protocol mandates all lines terminated by CRLF + if line[-2:] != '\r\n': + raise self.abort('socket error: unterminated line') line = line[:-2] if __debug__: @@ -1167,7 +1169,7 @@ while 1: char = self.sslobj.read(1) line.append(char) - if char == "\n": return ''.join(line) + if char in ("\n", ""): return ''.join(line) def send(self, data):