synx added the comment:

I dunno if this is helpful, but in the 2.5 module, it parses mailboxes
into rfc822 messages, but then expects them to be email.Message messages
when unparsing them back to a mailbox. mbox2.add(mbox1.popitem()[1])
fails with rfc822 as the default factory. Since the "factory" is the
only thing still using rfc822, it's easy to remove the use of rfc822
from this module entirely, which also eliminates the parsing/unparsing
disconnect.

----------
nosy: +synx
Added file: http://bugs.python.org/file8812/mailbox.py.patch

____________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue756982>
____________________________________
--- mailbox.py	2007-11-27 09:39:25.000000000 +0000
+++ mailbox.py	2007-11-27 09:39:17.000000000 +0000
@@ -18,7 +18,6 @@
 import email
 import email.Message
 import email.Generator
-import rfc822
 import StringIO
 try:
     if sys.platform == 'os2emx':
@@ -33,6 +32,9 @@
             'BabylMessage', 'MMDFMessage', 'UnixMailbox',
             'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ]
 
+def defaultFactory(fp):
+	return email.Parser.Parser().parse(fp)
+
 class Mailbox:
     """A group of messages in a particular place."""
 
@@ -225,7 +227,7 @@
 
     colon = ':'
 
-    def __init__(self, dirname, factory=rfc822.Message, create=True):
+    def __init__(self, dirname, factory=defaultFactory, create=True):
         """Initialize a Maildir instance."""
         Mailbox.__init__(self, dirname, factory, create)
         if not os.path.exists(self._path):
@@ -1906,7 +1908,7 @@
 
 class _Mailbox:
 
-    def __init__(self, fp, factory=rfc822.Message):
+    def __init__(self, fp, factory=defaultFactory):
         self.fp = fp
         self.seekp = 0
         self.factory = factory
@@ -2023,7 +2025,7 @@
 
 class MHMailbox:
 
-    def __init__(self, dirname, factory=rfc822.Message):
+    def __init__(self, dirname, factory=defaultFactory):
         import re
         pat = re.compile('^[1-9][0-9]*$')
         self.dirname = dirname
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to