python / cpython

The Python programming language
https://www.python.org
Other
63.23k stars 30.28k forks source link

mailbox.MH.add loses status info from other formats #76127

Open 6895b9b0-c852-4a8b-86aa-085fd8619049 opened 6 years ago

6895b9b0-c852-4a8b-86aa-085fd8619049 commented 6 years ago
BPO 31946
Nosy @warsaw, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['type-bug', 'library', 'expert-email'] title = 'mailbox.MH.add loses status info from other formats' updated_at = user = 'https://bugs.python.org/shai' ``` bugs.python.org fields: ```python activity = actor = 'shai' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)', 'email'] creation = creator = 'shai' dependencies = [] files = [] hgrepos = [] issue_num = 31946 keywords = [] message_count = 1.0 messages = ['305572'] nosy_count = 3.0 nosy_names = ['barry', 'r.david.murray', 'shai'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue31946' versions = ['Python 3.6'] ```

6895b9b0-c852-4a8b-86aa-085fd8619049 commented 6 years ago

In mailbox.py in the stdlib, the functions MH.add and MH.__setitem__ take a message object and dump it to a file in the MH folder, which is good and well. However, they only call self._dump_sequences() if the message was already an MHMessage.

Since in the MH format, status details (whether the message was read, replied or flagged) are saved in these sequences, this effectively loses this information.

This means that, if "folder" is an MH folder and "message" is a message of any class other than MHMessage,

   folder.add(message)

loses the information, while

   folder.add(MHMEssage(message))

retains it. This seems surprising and suboptimal.