Index: Doc/library/mailbox.rst =================================================================== --- Doc/library/mailbox.rst (revision 62996) +++ Doc/library/mailbox.rst (working copy) @@ -277,20 +277,16 @@ ^^^^^^^^^^^^^^^^ -.. class:: Maildir(dirname[, factory=rfc822.Message[, create=True]]) +.. class:: Maildir(dirname[, factory=None[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in Maildir format. Parameter *factory* is a callable object that accepts a file-like message representation (which behaves as if opened in binary mode) and returns a custom representation. If *factory* is ``None``, :class:`MaildirMessage` is used as the default message representation. If *create* is ``True``, the mailbox is created if it does not - exist. + exist. It is for historical reasons that *dirname* is named as such rather + than *path*. - It is for historical reasons that *factory* defaults to :class:`rfc822.Message` - and that *dirname* is named as such rather than *path*. For a :class:`Maildir` - instance that behaves like instances of other :class:`Mailbox` subclasses, set - *factory* to ``None``. - Maildir is a directory-based mailbox format invented for the qmail mail transfer agent and now widely supported by other programs. Messages in a Maildir mailbox are stored in separate files within a common directory Index: Lib/mailbox.py =================================================================== --- Lib/mailbox.py (revision 62996) +++ Lib/mailbox.py (working copy) @@ -18,7 +18,6 @@ import email import email.message import email.generator -import rfc822 import io try: if sys.platform == 'os2emx': @@ -223,7 +222,7 @@ colon = ':' - def __init__(self, dirname, factory=rfc822.Message, create=True): + def __init__(self, dirname, factory=None, create=True): """Initialize a Maildir instance.""" Mailbox.__init__(self, dirname, factory, create) if not os.path.exists(self._path): @@ -1932,7 +1931,7 @@ class _Mailbox: - def __init__(self, fp, factory=rfc822.Message): + def __init__(self, fp, factory=email.message_from_file): self.fp = fp self.seekp = 0 self.factory = factory @@ -2049,7 +2048,7 @@ class MHMailbox: - def __init__(self, dirname, factory=rfc822.Message): + def __init__(self, dirname, factory=email.message_from_file): import re pat = re.compile('^[1-9][0-9]*$') self.dirname = dirname Index: Lib/test/test_mailbox.py =================================================================== --- Lib/test/test_mailbox.py (revision 62996) +++ Lib/test/test_mailbox.py (working copy) @@ -526,7 +526,7 @@ # Initialize a non-existent mailbox self.tearDown() self._box = mailbox.Maildir(self._path) - self._check_basics(factory=rfc822.Message) + self._check_basics(factory=None) self._delete_recursively(self._path) self._box = self._factory(self._path, factory=None) self._check_basics() @@ -537,7 +537,7 @@ for subdir in '', 'tmp', 'new', 'cur': os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) self._box = mailbox.Maildir(self._path) - self._check_basics(factory=rfc822.Message) + self._check_basics(factory=None) self._box = mailbox.Maildir(self._path, factory=None) self._check_basics()