Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fe21e4d4
Commit
fe21e4d4
authored
Sep 27, 2014
by
Berker Peksag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16324: _charset parameter of MIMEText now also accepts email.charset.Charset instances.
Initial patch by Claude Paroz.
parent
081bbf6b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
1 deletion
+16
-1
Doc/library/email.mime.rst
Doc/library/email.mime.rst
+5
-1
Lib/email/mime/text.py
Lib/email/mime/text.py
+3
-0
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+4
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/email.mime.rst
View file @
fe21e4d4
...
@@ -195,7 +195,8 @@ Here are the classes:
...
@@ -195,7 +195,8 @@ Here are the classes:
set of the text and is passed as an argument to the
set of the text and is passed as an argument to the
:class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it defaults
:class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it defaults
to ``us-ascii`` if the string contains only ``ascii`` codepoints, and
to ``us-ascii`` if the string contains only ``ascii`` codepoints, and
``utf-8`` otherwise.
``utf-8`` otherwise. The *_charset* parameter accepts either a string or a
:class:`~email.charset.Charset` instance.
Unless the *_charset* argument is explicitly set to ``None``, the
Unless the *_charset* argument is explicitly set to ``None``, the
MIMEText object created will have both a :mailheader:`Content-Type` header
MIMEText object created will have both a :mailheader:`Content-Type` header
...
@@ -206,3 +207,6 @@ Here are the classes:
...
@@ -206,3 +207,6 @@ Here are the classes:
``Content-Transfer-Encoding`` header, after which a ``set_payload`` call
``Content-Transfer-Encoding`` header, after which a ``set_payload`` call
will automatically encode the new payload (and add a new
will automatically encode the new payload (and add a new
:mailheader:`Content-Transfer-Encoding` header).
:mailheader:`Content-Transfer-Encoding` header).
.. versionchanged:: 3.5
*_charset* also accepts :class:`~email.charset.Charset` instances.
Lib/email/mime/text.py
View file @
fe21e4d4
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
__all__
=
[
'MIMEText'
]
__all__
=
[
'MIMEText'
]
from
email.charset
import
Charset
from
email.mime.nonmultipart
import
MIMENonMultipart
from
email.mime.nonmultipart
import
MIMENonMultipart
...
@@ -34,6 +35,8 @@ class MIMEText(MIMENonMultipart):
...
@@ -34,6 +35,8 @@ class MIMEText(MIMENonMultipart):
_charset
=
'us-ascii'
_charset
=
'us-ascii'
except
UnicodeEncodeError
:
except
UnicodeEncodeError
:
_charset
=
'utf-8'
_charset
=
'utf-8'
if
isinstance
(
_charset
,
Charset
):
_charset
=
str
(
_charset
)
MIMENonMultipart
.
__init__
(
self
,
'text'
,
_subtype
,
MIMENonMultipart
.
__init__
(
self
,
'text'
,
_subtype
,
**
{
'charset'
:
_charset
})
**
{
'charset'
:
_charset
})
...
...
Lib/test/test_email/test_email.py
View file @
fe21e4d4
...
@@ -1636,6 +1636,10 @@ class TestMIMEText(unittest.TestCase):
...
@@ -1636,6 +1636,10 @@ class TestMIMEText(unittest.TestCase):
msg
=
MIMEText
(
'hello there'
,
_charset
=
'us-ascii'
)
msg
=
MIMEText
(
'hello there'
,
_charset
=
'us-ascii'
)
eq
(
msg
.
get_charset
().
input_charset
,
'us-ascii'
)
eq
(
msg
.
get_charset
().
input_charset
,
'us-ascii'
)
eq
(
msg
[
'content-type'
],
'text/plain; 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'
))
eq
(
msg
.
get_charset
().
input_charset
,
'utf-8'
)
eq
(
msg
[
'content-type'
],
'text/plain; charset="utf-8"'
)
def
test_7bit_input
(
self
):
def
test_7bit_input
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
Misc/ACKS
View file @
fe21e4d4
...
@@ -1024,6 +1024,7 @@ Peter Parente
...
@@ -1024,6 +1024,7 @@ Peter Parente
Alexandre Parenteau
Alexandre Parenteau
Dan Parisien
Dan Parisien
William Park
William Park
Claude Paroz
Heikki Partanen
Heikki Partanen
Harri Pasanen
Harri Pasanen
Gaël Pasgrimaud
Gaël Pasgrimaud
...
...
Misc/NEWS
View file @
fe21e4d4
...
@@ -10,6 +10,9 @@ Release date: TBA
...
@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #16324: _charset parameter of MIMEText now also accepts
email.charset.Charset instances. Initial patch by Claude Paroz.
- Issue #1764286: Fix inspect.getsource() to support decorated functions.
- Issue #1764286: Fix inspect.getsource() to support decorated functions.
Patch by Claudiu Popa.
Patch by Claudiu Popa.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment