Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8b7770

Browse files
committed
Issue #27445: Merge from 3.5
2 parents cc85449 + 2b2a9be commit d8b7770

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/email/mime/text.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ def __init__(self, _text, _subtype='plain', _charset=None, *, policy=None):
3535
_charset = 'us-ascii'
3636
except UnicodeEncodeError:
3737
_charset = 'utf-8'
38-
if isinstance(_charset, Charset):
39-
_charset = str(_charset)
4038

4139
MIMENonMultipart.__init__(self, 'text', _subtype, policy=policy,
42-
**{'charset': _charset})
40+
**{'charset': str(_charset)})
4341

4442
self.set_payload(_text, _charset)

Lib/test/test_email/test_email.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,9 +1653,12 @@ def test_charset(self):
16531653
eq(msg.get_charset().input_charset, 'us-ascii')
16541654
eq(msg['content-type'], 'text/plain; charset="us-ascii"')
16551655
# Also accept a Charset instance
1656-
msg = MIMEText('hello there', _charset=Charset('utf-8'))
1656+
charset = Charset('utf-8')
1657+
charset.body_encoding = None
1658+
msg = MIMEText('hello there', _charset=charset)
16571659
eq(msg.get_charset().input_charset, 'utf-8')
16581660
eq(msg['content-type'], 'text/plain; charset="utf-8"')
1661+
eq(msg.get_payload(), 'hello there')
16591662

16601663
def test_7bit_input(self):
16611664
eq = self.assertEqual

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ Core and Builtins
9292
Library
9393
-------
9494

95+
- Issue #27445: Don't pass str(_charset) to MIMEText.set_payload().
96+
Patch by Claude Paroz.
97+
9598
- Issue #24277: The new email API is no longer provisional, and the docs
9699
have been reorganized and rewritten to emphasize the new API.
97100

0 commit comments

Comments
 (0)