Author elenril
Recipients barry, elenril, r.david.murray
Date 2019-12-19.19:32:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576783934.54.0.946649596481.issue39100@roundup.psfhosted.org>
In-reply-to
Content
When parsing a (broken) mail from linux-media@vger.kernel.org (message-id 20190212181908.Horde.pEiGHvV2KHy9EkUy8TA8D1o@webmail.your-server.de, headers attached) with email.policy.SMTP, I get an AttributeError on trying to read the 'to' header:

/usr/lib/python3.7/email/headerregistry.py in <listcomp>(.0)
    345                                              mb.local_part or '',
    346                                              mb.domain or '')
--> 347                                      for mb in addr.all_mailboxes]))
    348             defects = list(address_list.all_defects)
    349         else:

AttributeError: 'Group' object has no attribute 'local_part'

The header in question is:
To:     unlisted-recipients:; (no To-header on input)

The problem seems to be that mb is a Group and not an Address, gets token_type of 'invalid-mailbox', but does not have the attributes local_part/domain that are expected in mailboxes. Copying the line

local_part = domain = route = addr_spec = display_name

from InvalidMailbox to Group fixes this, but it is not clear to me this is the right solution, so not sending a patch.
History
Date User Action Args
2019-12-19 19:32:14elenrilsetrecipients: + elenril, barry, r.david.murray
2019-12-19 19:32:14elenrilsetmessageid: <1576783934.54.0.946649596481.issue39100@roundup.psfhosted.org>
2019-12-19 19:32:14elenrillinkissue39100 messages
2019-12-19 19:32:14elenrilcreate