Remove a darwin-specific workaround for read()

Because of a buggy realloc() implementation in earlier versions of
Python on Mac OS X, we had to cut reads into manageable chunks by hand;
this is no more needed with Python 2.6, and besides it causes problems
with imaplib2, which we now use. Revert the special case to use the
system's read() instead, which is now safe.

Signed-off-by: Vincent Beffara <vbeffara@ens-lyon.fr>
Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Vincent Beffara 2011-03-22 15:51:42 +01:00 committed by Nicolas Sebrecht
parent 3f77afeb8a
commit 9a277cfd02

View File

@ -65,24 +65,7 @@ class UsefulIMAPMixIn:
def _mesg(self, s, tn=None, secs=None): def _mesg(self, s, tn=None, secs=None):
imaplibutil.new_mesg(self, s, tn, secs) imaplibutil.new_mesg(self, s, tn, secs)
class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
# This is a hack around Darwin's implementation of realloc() (which
# Python uses inside the socket code). On Darwin, we split the
# message into small chunks.
# see http://bugs.python.org/issue3531
def read(self, size):
if (system() == 'Darwin') and (size>0) :
read = 0
io = StringIO()
while read < size:
data = imaplib.IMAP4.read (self, min(size-read, 65536))
if not data:
break
read += len(data)
io.write(data)
return io.getvalue()
else:
return imaplib.IMAP4.read (self, size)
class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass