Merge branch 'ss/remove-uneeded-darwin-workaround' into next

This commit is contained in:
Nicolas Sebrecht 2011-03-05 16:37:35 +01:00
commit a271f90271

View File

@ -60,37 +60,23 @@ class UsefulIMAPMixIn:
imaplibutil.new_mesg(self, s, secs) imaplibutil.new_mesg(self, s, secs)
class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4):
# This is a hack around Darwin's implementation of realloc() (which # This is a hack around Darwin's implementation of realloc() (which
# Python uses inside the socket code). On Darwin, we split the # Python uses inside the socket code). On Darwin, we split the
# message into 100k chunks, which should be small enough - smaller # message into small chunks.
# might start seriously hurting performance ... # see http://bugs.python.org/issue3531
def read(self, size): def read(self, size):
if (system() == 'Darwin') and (size>0) : if (system() == 'Darwin') and (size>0) :
read = 0 read = 0
io = StringIO() io = StringIO()
while read < size: while read < size:
data = imaplib.IMAP4.read (self, min(size-read,8192)) data = imaplib.IMAP4.read (self, min(size-read, 65536))
read += len(data) read += len(data)
io.write(data) io.write(data)
return io.getvalue() return io.getvalue()
else: else:
return imaplib.IMAP4.read (self, size) return imaplib.IMAP4.read (self, size)
class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass
# This is the same hack as above, to be used in the case of an SSL
# connexion.
def read(self, size):
if (system() == 'Darwin') and (size>0) :
read = 0
io = StringIO()
while read < size:
data = imaplibutil.WrappedIMAP4_SSL.read (self, min(size-read,8192))
read += len(data)
io.write(data)
return io.getvalue()
else:
return imaplibutil.WrappedIMAP4_SSL.read (self,size)
class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass class UsefulIMAP4_Tunnel(UsefulIMAPMixIn, imaplibutil.IMAP4_Tunnel): pass