+ # This is a hack around Darwin's implementation of realloc() (which
+ # Python uses inside the socket code). On Darwin, we split the
+ # message into 100k chunks, which should be small enough - smaller
+ # might start seriously hurting performance ...
+
+ 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,8192))
+ read += len(data)
+ io.write(data)
+ return io.getvalue()
+ else:
+ return imaplib.IMAP4.read (self, size)
+