summaryrefslogtreecommitdiff
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
authorPiers Lauder <piers@cs.su.oz.au>2004-05-20 01:16:14 +0000
committerPiers Lauder <piers@cs.su.oz.au>2004-05-20 01:16:14 +0000
commit8f2b24401ee92cb90b5a75ef63dedfbfc883c140 (patch)
tree34ac432ea7fe52fc1c4df173261ca35d6e8e6d70 /Lib/imaplib.py
parent6e1fd2f20861a54d4690db92ce550a6fe24b8c33 (diff)
downloadcpython-git-8f2b24401ee92cb90b5a75ef63dedfbfc883c140.tar.gz
Fixed IMAP4_SSL read and readlines code per patch 956394
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index b70c47ca1c..96fdf834bf 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):