mirror of
https://github.com/python/cpython.git
synced 2024-12-01 11:15:56 +01:00
Issue #27445: Merge from 3.5
This commit is contained in:
commit
d8b7770a0e
@ -35,10 +35,8 @@ class MIMEText(MIMENonMultipart):
|
||||
_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)
|
||||
|
@ -1653,9 +1653,12 @@ class TestMIMEText(unittest.TestCase):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user