Title: mailbox should use email not rfc822
Type: Stage:
Components: Documentation, Library (Lib) Versions: Python 3.0, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, anthonybaxter, barry, benno37, georg.brandl, hdiogenes, jlgijsbers, synx
Priority: low Keywords: easy, patch

Created on 2003-06-19 02:19 by benno37, last changed 2008-05-11 21:31 by georg.brandl. This issue is now closed.

File name Uploaded Description Edit synx, 2007-11-27 09:49
mailbox-replace_rfc822.patch hdiogenes, 2008-05-11 07:33 Same patch updated. Removes all references to `rfc822` from mailbox and test_mailbox.
Messages (15)
msg16521 - (view) Author: Ben Leslie (benno37) Date: 2003-06-19 02:19
The mailbox module uses the rfc822 module as its
default factory for creating message objects. The
rfc822 documentation claims that its use is deprecated.
The mailbox module should probably use the new email
module as its default factory.

Of course this has backward compatibility issues, in
which case it should at least be mentioned in the
mailbox documentation that it uses the deprecated
rfc822 module, and provide an example of how to use the
email module instead.
msg16522 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2003-06-20 21:48
Logged In: YES 

I've added some sample code to the mailbox documentation
that explain how to use the email package with the mailbox
module.  We can't change the default for backward
compatibility reasons, as you point out.
msg16523 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2005-01-08 14:22
Logged In: YES 

So, with the plans to seriously start working deprecating
rfc822, should we use the email module as the default
factory now?
msg16524 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-01-08 15:49
Logged In: YES 

It's a good question.  I'd like to say yes so that we can
start adding deprecation warnings to rfc822 for Python 2.5.
msg16525 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2005-01-10 07:56
Logged In: YES 

Given the amount of code out there using rfc822, should we
instead PDW it? In any case, I'm -0 on putting a
DeprecationWarning on it unless we've removed all use of it
from the stdlib. 
msg16526 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2007-01-05 14:46
The reworking of introduced in Python 2.5 adds new mailbox classes that do use email.Message.  
Arguably we could begin deprecating the old classes (or just remove them all for Python 3000?).

msg57867 - (view) Author: synx (synx) Date: 2007-11-27 09:49
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
msg66587 - (view) Author: Humberto Diogenes (hdiogenes) Date: 2008-05-10 21:14
synx's patch wasn't applying cleanly and broke 2 maildir tests. I'm 
posting one with updated tests and documentation. Still need to get rid of 
rfc822 in test_mailbox, though.

Question: has one section marked as "classes from the original 
module (for backward compatibility)". Shouldn't these be removed in py3k?
msg66590 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2008-05-10 22:19
I think removing those old classes in 3.0 would be very sensible.
msg66598 - (view) Author: Humberto Diogenes (hdiogenes) Date: 2008-05-11 03:07
I created issue 2814 with a patch to remove those old classes.
msg66614 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 09:02
I removed the old classes in 3k. There remains one usage of rfc822, as
the default "factory" of Maildir. It's replaced by None in the patch
here; is that safe to do?
msg66656 - (view) Author: Humberto Diogenes (hdiogenes) Date: 2008-05-11 19:40
> rfc822 is replaced by None in the patch here; is that safe to do?

Yes. That's what mailbox documentation says:

Parameter factory is a callable object that accepts a file-like message 
representation [...] and returns a custom representation. If factory is 
None, MaildirMessage is used as the default message representation.
msg66667 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 20:51
Removed the last rfc822 reference from 3k's in r63091.
msg66672 - (view) Author: Humberto Diogenes (hdiogenes) Date: 2008-05-11 21:22
Georg, any special reason for not removing rfc822 references from 
test_mailbox? That section of the patch was not merged.
msg66673 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-05-11 21:31
Okay, removed that too in r63096.
Date User Action Args
2008-05-11 21:31:51georg.brandlsetmessages: + msg66673
2008-05-11 21:22:06hdiogenessetmessages: + msg66672
2008-05-11 20:51:33georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg66667
2008-05-11 19:41:00hdiogenessetmessages: + msg66656
2008-05-11 09:02:53georg.brandlsetnosy: + georg.brandl
messages: + msg66614
2008-05-11 07:33:28hdiogenessetfiles: -
2008-05-11 07:33:10hdiogenessetfiles: + mailbox-replace_rfc822.patch
keywords: + patch
2008-05-11 03:07:32hdiogenessetmessages: + msg66598
2008-05-10 22:19:57akuchlingsetmessages: + msg66590
2008-05-10 21:14:55hdiogenessetfiles: +
nosy: + hdiogenes
messages: + msg66587
2008-01-20 18:49:51christian.heimessetkeywords: + easy
components: + Documentation, Library (Lib), - Extension Modules
versions: + Python 2.6, Python 3.0, - Python 2.3
2008-01-09 21:29:36akuchlingsetassignee: barry -> akuchling
2007-11-27 09:49:21synxsetfiles: +
nosy: + synx
messages: + msg57867
2003-06-19 02:19:01benno37create