Stephen J. Turnbull added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27257> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com