[PATCH 1/3] Remove a darwin-specific workaround for read()

Vincent Beffara vbeffara at ens-lyon.fr
Tue Mar 22 14:51:42 GMT 2011


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 at ens-lyon.fr>
---
 offlineimap/imapserver.py |   19 +------------------
 1 files changed, 1 insertions(+), 18 deletions(-)

diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index f05c743..fc7a503 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -65,24 +65,7 @@ class UsefulIMAPMixIn:
     def _mesg(self, s, tn=None, secs=None):
         imaplibutil.new_mesg(self, s, tn, secs)
 
-class UsefulIMAP4(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4):
-    # 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(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4): pass
 
 class UsefulIMAP4_SSL(UsefulIMAPMixIn, imaplibutil.WrappedIMAP4_SSL): pass
 
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list