From 8f2b24401ee92cb90b5a75ef63dedfbfc883c140 Mon Sep 17 00:00:00 2001 From: Piers Lauder Date: Thu, 20 May 2004 01:16:14 +0000 Subject: Fixed IMAP4_SSL read and readlines code per patch 956394 --- Lib/imaplib.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Lib/imaplib.py b/Lib/imaplib.py index b70c47c..96fdf83 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -1100,21 +1100,24 @@ class IMAP4_SSL(IMAP4): def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes - data = self.sslobj.read(size) - while len(data) < size: - data += self.sslobj.read(size-len(data)) + chunks = [] + read = 0 + while read < size: + data = self.sslobj.read(size-read) + read += len(data) + chunks.append(size) - return data + return ''.join(chunks) def readline(self): """Read line from remote.""" # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method. - line = "" + line = [] while 1: char = self.sslobj.read(1) - line += char - if char == "\n": return line + line.append(char) + if char == "\n": return ''.join(line) def send(self, data): -- cgit v0.12