STINNER Victor <victor.stin...@haypocalc.com> added the comment: mailbox.patch: - open files in binary mode not as text - parse as bytes not as Unicode - replace email.generator.Generator() by email.generator.BytesGenerator() - use .message_from_bytes() instead of .message_from_str() - use .message_from_binary_file() instead of .message_from_file() - use BytesIO() instead of StringIO() - add more methods to _ProxyFile: readable, writable, seekable, flush, closed - don't use universal newline (not supported by binary files): I don't remember if the email binary parser supports directly universal newline
I don't know anything about the mailbox module. I just replaced str functions by bytes functions. Keep Unicode for some things: MH.get_sequence() reads the file using UTF-8 encoding, labels and sequences. The patch have to be tested on Windows (Windows uses \r\n newline). I only tested on Linux. ---------- keywords: +patch Added file: http://bugs.python.org/file20522/mailbox.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9124> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com