diff options
Diffstat (limited to 'Lib/mailbox.py')
| -rw-r--r-- | Lib/mailbox.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index 325b9c9ac0..7a29555e4a 100644 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1462,9 +1462,10 @@ class Message(email.message.Message): def _become_message(self, message): """Assume the non-format-specific state of message.""" - for name in ('_headers', '_unixfrom', '_payload', '_charset', - 'preamble', 'epilogue', 'defects', '_default_type'): - self.__dict__[name] = message.__dict__[name] + type_specific = getattr(message, '_type_specific_attributes', []) + for name in message.__dict__: + if name not in type_specific: + self.__dict__[name] = message.__dict__[name] def _explain_to(self, message): """Copy format-specific state to message insofar as possible.""" @@ -1477,6 +1478,8 @@ class Message(email.message.Message): class MaildirMessage(Message): """Message with Maildir-specific properties.""" + _type_specific_attributes = ['_subdir', '_info', '_date'] + def __init__(self, message=None): """Initialize a MaildirMessage instance.""" self._subdir = 'new' @@ -1584,6 +1587,8 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): """Message with mbox- or MMDF-specific properties.""" + _type_specific_attributes = ['_from'] + def __init__(self, message=None): """Initialize an mboxMMDFMessage instance.""" self.set_from('MAILER-DAEMON', True) @@ -1699,6 +1704,8 @@ class mboxMessage(_mboxMMDFMessage): class MHMessage(Message): """Message with MH-specific properties.""" + _type_specific_attributes = ['_sequences'] + def __init__(self, message=None): """Initialize an MHMessage instance.""" self._sequences = [] @@ -1769,6 +1776,8 @@ class MHMessage(Message): class BabylMessage(Message): """Message with Babyl-specific properties.""" + _type_specific_attributes = ['_labels', '_visible'] + def __init__(self, message=None): """Initialize an BabylMessage instance.""" self._labels = [] |
