Karl Fogel <[email protected]> added the comment:
I can also confirm this bug, with Python 3.9.1 on Debian GNU/Linux ('testing'
distro up-to-date as of 2020-12-21).
1) Create a parser `p` with `p =
email.parser.HeaderParser(policy=email.policy.default)`.
2) Parse a single problematic (as described below) message: `msg_headers =
p.parsestr(msg_str)`
3) Try to get the To field: `msg_headers.get_all('to', [ ])` and get an
exception raised: `AttributeError: 'str' object has no attribute 'token_type'`
(with the same stack trace as OP shows).
Here is a minimal problematic message you can reproduce this with (i.e., just
make `msg_str` have this string value):
```
>From nobody Mon Dec 21 12:00:00 2020
From: [email protected]
To: . <[email protected]>
Date: Mon, 21 Dec 2020 12:00:00 -0000
Message-ID: <[email protected]>
Subject: This is the Subject header.
Here is the body of the message.
```
Note that *any* number of dots for the recipient's name would also result in an
error. The above example uses just ".", but it could be "..", "...",
".................", etc.
----------
nosy: +kfogel
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue30988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com