This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rpatterson
Recipients barry, r.david.murray, rpatterson
Date 2013-03-20.18:15:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363803336.58.0.787199828624.issue17495@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-03-20 18:15:36rpattersonsetrecipients: + rpatterson, barry, r.david.murray
2013-03-20 18:15:36rpattersonsetmessageid: <1363803336.58.0.787199828624.issue17495@psf.upfronthosting.co.za>
2013-03-20 18:15:36rpattersonlinkissue17495 messages
2013-03-20 18:15:36rpattersoncreate