-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port relevant patches for SF 1409455 to the trunk for email 3.0/Pytho…
…n 2.5. Will port to Python 2.4.
- Loading branch information
Showing
5 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2001-2004 Python Software Foundation | ||
# Copyright (C) 2001-2006 Python Software Foundation | ||
# Author: Ben Gertzfield, Barry Warsaw | ||
# Contact: [email protected] | ||
|
||
|
@@ -206,7 +206,7 @@ def __init__(self, input_charset=DEFAULT_CHARSET): | |
self.input_codec = CODEC_MAP.get(self.input_charset, | ||
self.input_charset) | ||
self.output_codec = CODEC_MAP.get(self.output_charset, | ||
self.output_charset) | ||
self.output_charset) | ||
|
||
def __str__(self): | ||
return self.input_charset.lower() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2001-2004 Python Software Foundation | ||
# Copyright (C) 2001-2006 Python Software Foundation | ||
# Author: Barry Warsaw | ||
# Contact: [email protected] | ||
|
||
|
@@ -175,9 +175,6 @@ def _handle_text(self, msg): | |
payload = msg.get_payload() | ||
if payload is None: | ||
return | ||
cset = msg.get_charset() | ||
if cset is not None: | ||
payload = cset.body_encode(payload) | ||
if not isinstance(payload, basestring): | ||
raise TypeError('string payload expected: %s' % type(payload)) | ||
if self._mangle_from_: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Copyright (C) 2002 Python Software Foundation | ||
# Copyright (C) 2002-2006 Python Software Foundation | ||
# Contact: [email protected] | ||
# email package unit tests for (optional) Asian codecs | ||
|
||
import unittest | ||
|
@@ -7,6 +8,8 @@ | |
from email.test.test_email import TestEmailBase | ||
from email.Charset import Charset | ||
from email.Header import Header, decode_header | ||
from email.Message import Message | ||
|
||
|
||
|
||
class TestEmailAsianCodecs(TestEmailBase): | ||
|
@@ -42,6 +45,14 @@ def test_japanese_codecs(self): | |
# TK: full decode comparison | ||
eq(h.__unicode__().encode('euc-jp'), long) | ||
|
||
def test_payload_encoding(self): | ||
jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa' | ||
jcode = 'euc-jp' | ||
msg = Message() | ||
msg.set_payload(jhello, jcode) | ||
ustr = unicode(msg.get_payload(), msg.get_content_charset()) | ||
self.assertEqual(jhello, ustr.encode(jcode)) | ||
|
||
|
||
|
||
def suite(): | ||
|