Asheesh Laroia <[EMAIL PROTECTED]> added the comment:
Another way to see this issue is that the email module double-encodes
when one attempts to use quoted-printable encoding. This has to be
worked around by e.g. MoinMoin.
It's easy to get proper base64-encoded output of email.mime.text:
>>> mt = email.mime.text.MIMEText('Ta mère', 'plain', 'utf-8')
>>> 'Content-Transfer-Encoding: base64' in mt.as_string()
True
>>> mt.as_string().split('\n')[-2]
'VGEgbcOocmU='
There we go, all nice and base64'd.
I can *not* figure out how to get quoted-printable-encoding. I found
http://docs.python.org/lib/module-email.encoders.html , so I thought
great - I'll just encode my MIMEText object:
>>> email.encoders.encode_quopri(mt)
>>> 'Content-Transfer-Encoding: quoted-printable' in mt.as_string()
True
Great! Except it's actually double-encoded, and the headers admit to as
much. You see here that, in addition to the quoted-printable header
just discovered, there is also a base64-related header, and the result
is not strictly QP encoding but QP(base64(payload)).
>>> 'Content-Transfer-Encoding: base64' in mt.as_string()
True
>>> mt.as_string().split('\n')[-2]
'VGEgbcOocmU=3D'
It should look like:
>>> quopri.encodestring('Ta mère')
'Ta m=C3=A8re'
I raised this issue on the Baypiggies list
<http://mail.python.org/pipermail/baypiggies/2008-September/003983.html>, but
luckily I found this here bug. This is with Python 2.5.2-0ubuntu1 from
Ubuntu 8.04.
[EMAIL PROTECTED]:~ $ python --version
Python 2.5.2
If we can come to a decision as to how this *should* work, I could
contribute a patch and/or tests to fix it. I could even perhaps write a
new section of the Python documentation of the email module explaining this.
----------
nosy: +paulproteus
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1525919>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com