New submission from Ross Patterson: When using email.charset.Charset to encode MIME bodie as quoted-printable, some characters that are encodable with the quopri_codec cause a KeyError in email.quoprimime:
Python 3.3.0 (default, Oct 7 2012, 14:43:21) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> text_encoded = b'mo \xe2\x82\xac' >>> text = text_encoded.decode('utf-8') >>> print(text) mo € >>> import codecs >>> codecs.getencoder('quopri_codec')(text_encoded)[0] b'mo=20=E2=82=AC' >>> from email import charset >>> c = charset.Charset('utf-8') >>> c.header_encoding = charset.QP >>> c.body_encoding = charset.QP >>> c.header_encode(text) '=?utf-8?q?mo_=E2=82=AC?=' >>> c.body_encode(text) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/email/charset.py", line 395, in body_encode return email.quoprimime.body_encode(string) File "/usr/lib/python3.3/email/quoprimime.py", line 240, in body_encode if body_check(ord(c)): File "/usr/lib/python3.3/email/quoprimime.py", line 81, in body_check return chr(octet) != _QUOPRI_BODY_MAP[octet] KeyError: 8364 ---------- components: email messages: 184772 nosy: barry, r.david.murray, rpatterson priority: normal severity: normal status: open title: email.quoprimime.body_encode can't handle characters that encodings.quopri_codec can type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17495> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com