Skip to content

Commit

Permalink
Issue python#27445: Merge from 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
berkerpeksag committed Sep 8, 2016
2 parents cc85449 + 2b2a9be commit d8b7770
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Lib/email/mime/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def __init__(self, _text, _subtype='plain', _charset=None, *, policy=None):
_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)
5 changes: 4 additions & 1 deletion Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,9 +1653,12 @@ def test_charset(self):
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
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Core and Builtins
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.

Expand Down

0 comments on commit d8b7770

Please sign in to comment.