homepage

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.message.Message.set_payload and as_string given charset 'us-ascii' plus 8bit data produces invalid message
Type: behavior Stage: test needed
Components: email Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, mitya57, r.david.murray
Priority: normal Keywords:

Created on 2009年11月10日 22:32 by r.david.murray, last changed 2022年04月11日 14:56 by admin.

Messages (2)
msg95133 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009年11月10日 22:32
The following produces a non-conformant message, since the us-ascii
charset is strictly 7bit:
>>> import email.message
>>> m = email.message.Message()
>>> m.set_payload("""A few lines
... of 8-bit text
...
... One high bit character: 2.
... """, 'us-ascii')
>>> print m.as_string()
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
A few lines
of 8-bit text
One high bit character: 2.
>>>
msg156629 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012年03月23日 01:55
In Python2 the fix would be to use charset unknown-8bit instead of us-ascii.
In Python3 this actually puts unicode in the message body. There we should default to utf-8, but this requires a more extensive change than the Python2 change, and probably should not be backported.
Once this is fixed in Python3 the utf-8 default check can be removed from MIMEText (issue 14380).
History
Date User Action Args
2022年04月11日 14:56:54adminsetgithub: 51553
2012年06月06日 08:33:05mitya57setnosy: + mitya57
2012年05月24日 14:51:48r.david.murraysetassignee: r.david.murray ->
components: + email, - Library (Lib)
2012年03月23日 01:55:44r.david.murraysetmessages: + msg156629
versions: + Python 3.3, - Python 3.1
2012年03月23日 01:33:36r.david.murraysetassignee: r.david.murray
2010年07月11日 10:20:55BreamoreBoysetnosy: + barry

versions: - Python 2.6
2009年11月10日 22:32:46r.david.murraycreate

AltStyle によって変換されたページ (->オリジナル) /