An unfortunate combination of get_all and getaddresses results in a Traceback:
Traceback (most recent call last):
File "misc/decode_from_header.py", line 17, in <module>
print('From: %s' % email.utils.getaddresses(val))
File "/usr/lib64/python3.4/email/utils.py", line 112, in getaddresses
all = COMMASPACE.join(fieldvalues)
TypeError: sequence item 0: expected str instance, Header found
Here's the relevant part of it:
Content-type: text/html;charset=iso-8859-1
From: Itaú Uniclass. <comunicado.com.br@atendimento.gotdns.ch>
Obviously, the From header is iso-8859-1 encoded as well, and violates RFC 2822 as such. But making it crash in the usual combination of
val = msg.get('from')
email.utils.getaddresses([val])
isn't the real McCoy either..