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.

classification
Title: Contradictory documentation for email.mime.text.MIMEText
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: barry, eric.araujo, georg.brandl, l0nwlf, pitrou, r.david.murray
Priority: normal Keywords: patch

Created on 2009-07-19 13:19 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
email.mime.rst.patch l0nwlf, 2010-04-13 04:12 explicitly mentions the unavailibilty of Unicode support
Messages (4)
msg90711 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-07-19 13:19
It is not obvious whether encoding of an unicode argument will happen or
not:

« [...] No guessing or encoding is performed on the text data.

Changed in version 2.4: The previously deprecated _encoding argument has
been removed. Encoding happens implicitly based on the _charset argument. »

http://docs.python.org/library/email.mime.html#email.mime.text.MIMEText
msg90712 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-07-19 13:21
Apparently it doesn't:

>>> message = MIMEText(u"héhé", _charset="utf-8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/email/mime/text.py", line 30, in __init__
    self.set_payload(_text, _charset)
  File "/usr/lib64/python2.6/email/message.py", line 224, in set_payload
    self.set_charset(charset)
  File "/usr/lib64/python2.6/email/message.py", line 266, in set_charset
    self._payload = charset.body_encode(self._payload)
  File "/usr/lib64/python2.6/email/charset.py", line 387, in body_encode
    return email.base64mime.body_encode(s)
  File "/usr/lib64/python2.6/email/base64mime.py", line 147, in encode
    enc = b2a_base64(s[i:i + max_unencoded])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 1: ordinal not in range(128)
msg103009 - (view) Author: Shashwat Anand (l0nwlf) Date: 2010-04-13 04:12
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)

The lack of unicode encoding support should be mentioned explicitly.
Attaching a doc patch.
msg106871 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-06-02 01:09
This is not quite a duplicate of issue 1368247, but in the patch for that issue the doc changes should clarify the ambiguity.
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50770
2010-06-02 01:09:28r.david.murraysetstatus: open -> closed
type: behavior
messages: + msg106871

resolution: duplicate
stage: needs patch -> resolved
2010-05-05 19:35:05eric.araujosetnosy: barry, georg.brandl, pitrou, eric.araujo, r.david.murray, l0nwlf
2010-05-05 13:34:19barrysetassignee: barry -> r.david.murray
2010-04-13 04:12:19l0nwlfsetfiles: + email.mime.rst.patch

nosy: + l0nwlf, r.david.murray
messages: + msg103009

keywords: + patch
2010-02-16 06:18:28eric.araujosetnosy: + eric.araujo
2009-07-19 13:39:39georg.brandlsetassignee: georg.brandl -> barry

nosy: + barry
2009-07-19 13:21:54pitrousetmessages: + msg90712
2009-07-19 13:19:39pitroucreate