changeset: 103313:c5cb8bd335ae parent: 103311:eab3422911e4 parent: 103312:4f6fef83cd0c user: Berker Peksag date: Thu Sep 08 19:42:11 2016 +0300 files: Lib/email/mime/text.py Lib/test/test_email/test_email.py Misc/NEWS description: Issue #27445: Merge from 3.5 diff -r eab3422911e4 -r c5cb8bd335ae Lib/email/mime/text.py --- a/Lib/email/mime/text.py Thu Sep 08 09:29:11 2016 -0700 +++ b/Lib/email/mime/text.py Thu Sep 08 19:42:11 2016 +0300 @@ -35,10 +35,8 @@ _charset = 'us-ascii' except UnicodeEncodeError: _charset = 'utf-8' - if isinstance(_charset, Charset): - _charset = str(_charset) MIMENonMultipart.__init__(self, 'text', _subtype, policy=policy, - **{'charset': _charset}) + **{'charset': str(_charset)}) self.set_payload(_text, _charset) diff -r eab3422911e4 -r c5cb8bd335ae Lib/test/test_email/test_email.py --- a/Lib/test/test_email/test_email.py Thu Sep 08 09:29:11 2016 -0700 +++ b/Lib/test/test_email/test_email.py Thu Sep 08 19:42:11 2016 +0300 @@ -1653,9 +1653,12 @@ eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"') # Also accept a Charset instance - msg = MIMEText('hello there', _charset=Charset('utf-8')) + charset = Charset('utf-8') + charset.body_encoding = None + msg = MIMEText('hello there', _charset=charset) eq(msg.get_charset().input_charset, 'utf-8') eq(msg['content-type'], 'text/plain; charset="utf-8"') + eq(msg.get_payload(), 'hello there') def test_7bit_input(self): eq = self.assertEqual diff -r eab3422911e4 -r c5cb8bd335ae Misc/NEWS --- a/Misc/NEWS Thu Sep 08 09:29:11 2016 -0700 +++ b/Misc/NEWS Thu Sep 08 19:42:11 2016 +0300 @@ -92,6 +92,9 @@ Library ------- +- Issue #27445: Don't pass str(_charset) to MIMEText.set_payload(). + Patch by Claude Paroz. + - Issue #24277: The new email API is no longer provisional, and the docs have been reorganized and rewritten to emphasize the new API.