This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mailbox: Implement >From_ decoding on input from mbox
Type: enhancement Stage: needs patch
Components: email Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, bpoaugust, r.david.murray
Priority: normal Keywords:

Created on 2016-12-23 14:16 by bpoaugust, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
mboxo_patch.py bpoaugust, 2016-12-24 01:54
Messages (5)
msg283879 - (view) Author: (bpoaugust) Date: 2016-12-23 14:16
The email package implements mboxo From_ mangling on output by default.

However there is no provision to unmangle >From_ on input.

This means that it's not possible to import mboxo files correctly.
msg283882 - (view) Author: (bpoaugust) Date: 2016-12-23 14:27
Is there any way to override the current behaviour?
msg283883 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-12-23 14:43
Not easily.  Making the feedparser more pluggable is on my wish list, but at this point someone would have to fund me for work on the email package before I'd be able to even clear the backlog to think about it :)

I'd say accepting this as a new feature is a no-brainer, if you want to work on a patch.  Make enabling it a Policy option that defaults to the current behavior.
msg283914 - (view) Author: (bpoaugust) Date: 2016-12-24 01:54
Attached please find patch which works for me.

To use it independently of email, do something like:

messages = mailbox.mbox(filename, MboxoFactory)

where:

class MboxoFactory(mailbox.mboxMessage):
    def __init__(self, message=None):
        super().__init__(message=MboxoReader(message))

HTH
msg284500 - (view) Author: (bpoaugust) Date: 2017-01-02 20:42
The patch can be simplified by just looking for b'\n' in the last 6 chars, and caching from b'\n' if found.

This would mean more file seeking in exchange for less buffer matching.
History
Date User Action Args
2022-04-11 14:58:41adminsetgithub: 73239
2017-01-03 12:21:51vstinnersettitle: Implement >From_ decoding on input from mbox -> mailbox: Implement >From_ decoding on input from mbox
2017-01-02 20:42:43bpoaugustsetmessages: + msg284500
2016-12-29 20:49:40bpoaugustsetversions: + Python 3.5, - Python 3.7
2016-12-24 01:54:40bpoaugustsetfiles: + mboxo_patch.py

messages: + msg283914
2016-12-23 14:43:12r.david.murraysettype: behavior -> enhancement
stage: needs patch
messages: + msg283883
versions: + Python 3.7
2016-12-23 14:27:34bpoaugustsetmessages: + msg283882
2016-12-23 14:16:48bpoaugustcreate