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.

Author sjt
Recipients barry, frispete, r.david.murray, sjt
Date 2016-06-08.14:04:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465394696.97.0.221090460463.issue27257@psf.upfronthosting.co.za>
In-reply-to
Content
OK, I can reproduce now.

$ python3.5
Python 3.5.0 (v3.5.0:374f501f4567, Sep 17 2015, 17:04:56) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> with open(b'lkml-exception.mail', mode = 'r') as f:
...  msg = email.message_from_file(f, policy=email.policy.SMTP)
... 
>>> msg.get_all('to')
Traceback (most recent call last):

and (except for a slight skew in line-numbering) the rest is the same as the tail of the OP.

The crucial part is the policy=email.policy.SMTP argument, and evidently what's happening is that the parser assumes that the local-part of the addr-spec is non-empty.  RFC5322 does permit a quoted-string to be empty, so this is a bug in the email module's parser.  (I don't have a patch,sorry.)

Aside: although strictly speaking it's hold-your-nose-and-avert-your-eyes legal according to RFC 5322, RFC 5321 (SMTP) does say:

   While the above definition for Local-part is relatively permissive,
   for maximum interoperability, a host that expects to receive mail
   SHOULD avoid defining mailboxes where the Local-part requires (or
   uses) the Quoted-string form[...].

I don't see a good reason for the usage in the test case, so I'd call this nonconformant to RFC 5321.  I think the right way to handle it is to register a defect but let the parse succeed.
History
Date User Action Args
2016-06-08 14:04:57sjtsetrecipients: + sjt, barry, frispete, r.david.murray
2016-06-08 14:04:56sjtsetmessageid: <1465394696.97.0.221090460463.issue27257@psf.upfronthosting.co.za>
2016-06-08 14:04:56sjtlinkissue27257 messages
2016-06-08 14:04:56sjtcreate