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
f315ec52
Commit
f315ec52
authored
Mar 13, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1449244: Support Unicode strings in
email.message.Message.{set_charset,get_content_charset}.
parent
e14d44fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
Lib/email/message.py
Lib/email/message.py
+4
-2
Lib/email/test/test_email.py
Lib/email/test/test_email.py
+7
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/message.py
View file @
f315ec52
...
...
@@ -238,7 +238,7 @@ class Message:
self.del_param('charset')
self._charset = None
return
if isinstance(charset,
str
):
if isinstance(charset,
basestring
):
charset = email.charset.Charset(charset)
if not isinstance(charset, email.charset.Charset):
raise TypeError(charset)
...
...
@@ -756,7 +756,9 @@ class Message:
charset = charset[2]
# charset character must be in us-ascii range
try:
charset = unicode(charset, 'us-ascii').encode('us-ascii')
if isinstance(charset, str):
charset = unicode(charset, 'us-ascii')
charset = charset.encode('us-ascii')
except UnicodeError:
return failobj
# RFC 2046, $4.1.2 says charsets are not case sensitive
...
...
Lib/email/test/test_email.py
View file @
f315ec52
...
...
@@ -502,6 +502,13 @@ class TestMessageAPI(TestEmailBase):
msg
.
set_payload
(
x
)
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
x
)
def
test_get_content_charset
(
self
):
msg
=
Message
()
msg
.
set_charset
(
'us-ascii'
)
self
.
assertEqual
(
'us-ascii'
,
msg
.
get_content_charset
())
msg
.
set_charset
(
u'us-ascii'
)
self
.
assertEqual
(
'us-ascii'
,
msg
.
get_content_charset
())
# Test the email.Encoders module
...
...
Misc/NEWS
View file @
f315ec52
...
...
@@ -202,6 +202,9 @@ Extension Modules
Library
-------
-
Patch
#
1449244
:
Support
Unicode
strings
in
email
.
message
.
Message
.{
set_charset
,
get_content_charset
}.
-
Patch
#
1542681
:
add
entries
for
"with"
,
"as"
and
"CONTEXTMANAGERS"
to
pydoc
's help keywords.
...
...
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