Karl Fogel <kfo...@red-bean.com> 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: sen...@example.com
To: . <jran...@example.com>
Date: Mon, 21 Dec 2020 12:00:00 -0000
Message-ID: <87ab5rvds7....@example.com>
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 <rep...@bugs.python.org>
<https://bugs.python.org/issue30988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to