summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-05-05 17:31:03 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-05-05 17:31:03 (GMT)
commit7d93221a5c159ce506b2a557777d1a1751c7f743 (patch)
treed57b1f6f042e0b88ebb53eb88ab8847383aa3357 /Lib/email
parentb26dc46576dadd72d608571c021cccc13f4cd8bf (diff)
downloadcpython-7d93221a5c159ce506b2a557777d1a1751c7f743.zip
cpython-7d93221a5c159ce506b2a557777d1a1751c7f743.tar.gz
cpython-7d93221a5c159ce506b2a557777d1a1751c7f743.tar.bz2
Issue #7472: remove unused code from email.encoders.encode_7or8bit.
Yukihiro Nakadaira noticed a typo in encode_7or8bit that was trying to special case iso-2022 codecs. It turns out that the code in question is never used, because whereas it was designed to trigger if the payload encoding was eight bit but its output encoding was 7 bit, in practice the payload is always converted to the 7bit encoding before encode_7or8bit is called. Patch by Shawat Anand.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/encoders.py8
-rw-r--r--Lib/email/test/test_email.py7
2 files changed, 8 insertions, 7 deletions
diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
index c1a44aa..af45e62 100644
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -72,13 +72,7 @@ def encode_7or8bit(msg):
try:
orig.encode('ascii')
except UnicodeError:
- # iso-2022-* is non-ASCII but still 7-bit
- charset = msg.get_charset()
- output_cset = charset and charset.output_charset
- if output_cset and output_cset.lower().startswith('iso-2022-'):
- msg['Content-Transfer-Encoding'] = '7bit'
- else:
- msg['Content-Transfer-Encoding'] = '8bit'
+ msg['Content-Transfer-Encoding'] = '8bit'
else:
msg['Content-Transfer-Encoding'] = '7bit'
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 01d2a67..bf41be7 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -564,6 +564,13 @@ class TestEncoders(unittest.TestCase):
msg = MIMEText('hello \xf8 world', _charset='iso-8859-1')
eq(msg['content-transfer-encoding'], 'quoted-printable')
+ def test_encode7or8bit(self):
+ # Make sure a charset whose input character set is 8bit but
+ # whose output character set is 7bit gets a transfer-encoding
+ # of 7bit.
+ eq = self.assertEqual
+ msg = email.MIMEText.MIMEText('\xca\xb8', _charset='euc-jp')
+ eq(msg['content-transfer-encoding'], '7bit')
# Test long header wrapping