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: email module base64-encodes utf-8 text
Type: behavior Stage: resolved
Components: email, Library (Lib) Versions: Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: barry, jribbens, r.david.murray
Priority: normal Keywords:

Created on 2017-04-10 17:45 by jribbens, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg291435 - (view) Author: Jon Ribbens (jribbens) * Date: 2017-04-10 17:45
The email module, when creating text parts using character encoding utf-8, base64-encodes the output even though this is often inappropriate (e.g. if it is a Western language it is almost never appropriate).

>>> from email.mime.text import MIMEText
>>> m = MIMEText("hello", _charset="utf-8")
>>> m.as_string()
'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: base64\n\naGVsbG8=\n'
msg291439 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-04-10 18:23
Yes, this sub-optimal, but it's the way it works in the legacy API, and we aren't going to change the legacy (compat32) API at this point.  The new policies and the new API in python3 handle this sensibly.
msg291445 - (view) Author: Jon Ribbens (jribbens) * Date: 2017-04-10 18:54
Just a note for anyone finding this in searching results: it appears that what David means by "python3 API" is actually a new API in Python 3.6 (email.message.EmailMessage).
msg291449 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-04-10 19:16
The API exists in python3.5 and python3.4 as well, it was just provisional.  Very few things changed between the provisional version and the final version in 3.6.
History
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74219
2017-04-10 19:16:35r.david.murraysetmessages: + msg291449
2017-04-10 18:54:52jribbenssetmessages: + msg291445
2017-04-10 18:23:53r.david.murraysetstatus: open -> closed
resolution: out of date
messages: + msg291439

stage: resolved
2017-04-10 18:08:19serhiy.storchakasetnosy: + barry, r.david.murray
components: + email
2017-04-10 17:45:40jribbenscreate