[issue11243] email/message.py str conversion

Steffen Daode Nurpmeso report at bugs.python.org
Wed Mar 16 16:09:53 CET 2011


Steffen Daode Nurpmeso <sdaoden at googlemail.com> added the comment:

Sorry, i've forgot the test ;)

----------
Added file: http://bugs.python.org/file21241/11243-test.1.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11243>
_______________________________________
-------------- next part --------------
import sys,email

data = r'''Date: Mon, 17 Jan 2011 01:10:29 -0200 (BRST)
From: "Pank! é bom demais." <no-reply at pank.com.br>
To: <misc at openbsd.org>
Subject: =?iso-8859-1?Q?Pague_R$50,00_por_R$100,00_em_compras_e_aproveite_a_melhor?= =?iso-8859-1?Q?_sele=E7=E3o_de_perfumes_e_cosm=E9ticos_com_pre=E7os_imper?= =?iso-8859-1?Q?d=EDveis!?=
Message-ID: <20110117031029.DE4ED568469 at al88.auinmeio.com.br>

'''

msg = email.message_from_string(data)
allh = msg.items()[:]
if len(allh):
    for (f, b) in allh:
        del msg[f]
    for (f, b) in allh:
        msg[f] = email.header.make_header(email.header.decode_header(b))

print(msg)



More information about the Python-bugs-list mailing list