Hi everyone, I am trying to use imaplib to download messages, but I keep getting memory errors when I try to download a large message (i.e. one with attachments). Here is my test code (similar to the example in the imaplib documentation):
import getpass, imaplib M = imaplib.IMAP4_SSL("imap.gmail.com") M.login("[EMAIL PROTECTED]", getpass.getpass()) M.select("[Gmail]/All Mail") typ, data = M.search(None, 'ALL') for num in data[0].split(): typ, data = M.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data[0][1]) M.close() M.logout() And here is the error message: Python(4521) malloc: *** mmap(size=6389760) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Traceback (most recent call last): File "imaptest.py", line 8, in <module> typ, data = M.fetch(num, '(RFC822)') File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 437, in fetch typ, dat = self._simple_command(name, message_set, message_parts) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 1055, in _simple_command return self._command_complete(name, self._command(name, *args)) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 885, in _command_complete typ, data = self._get_tagged_response(tag) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 986, in _get_tagged_response self._get_response() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 948, in _get_response data = self.read(size) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/imaplib.py", line 1150, in read data = self.sslobj.read(size-read) MemoryError I am using Mac OS X 10.5 and Python 2.5.1 (downloaded from python.org). I think it is possible that it is <http://bugs.python.org/ issue1092502>, but the workarounds suggested there do not seem to work for me. Is this an actual Python bug, or am I doing something wrong? -- http://mail.python.org/mailman/listinfo/python-list