New submission from Anton Khirnov <an...@khirnov.net>:

When parsing a (broken) mail from linux-me...@vger.kernel.org (message-id 
20190212181908.horde.peighvv2khy9ekuy8ta8...@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.

----------
components: email
files: mail.eml
messages: 358689
nosy: barry, elenril, r.david.murray
priority: normal
severity: normal
status: open
title: email.policy.SMTP throws AttributeError on invalid header
type: behavior
Added file: https://bugs.python.org/file48792/mail.eml

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39100>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to