diff options
author | Piers Lauder <piers@cs.su.oz.au> | 2004-05-20 01:16:14 (GMT) |
---|---|---|
committer | Piers Lauder <piers@cs.su.oz.au> | 2004-05-20 01:16:14 (GMT) |
commit | 8f2b24401ee92cb90b5a75ef63dedfbfc883c140 (patch) | |
tree | 34ac432ea7fe52fc1c4df173261ca35d6e8e6d70 /Lib/imaplib.py | |
parent | 6e1fd2f20861a54d4690db92ce550a6fe24b8c33 (diff) | |
download | cpython-8f2b24401ee92cb90b5a75ef63dedfbfc883c140.zip cpython-8f2b24401ee92cb90b5a75ef63dedfbfc883c140.tar.gz cpython-8f2b24401ee92cb90b5a75ef63dedfbfc883c140.tar.bz2 |
Fixed IMAP4_SSL read and readlines code per patch 956394
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r-- | Lib/imaplib.py | 17 |
1 files 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): |