summaryrefslogtreecommitdiff
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2007-08-31 03:26:19 +0000
committerBarry Warsaw <barry@python.org>2007-08-31 03:26:19 +0000
commita39b3edce5eaec02b6e31b7e228b2ee2b000081d (patch)
treee9889d268f4dd7427227637dbfac16024cb2f619 /Lib/email
parent0724f49501ece9ea3e4021e11e0f36be1c57a884 (diff)
downloadcpython-a39b3edce5eaec02b6e31b7e228b2ee2b000081d.tar.gz
More email package fixes.
Fix a couple of tests since .body_encode()'s arguments have changed. Also, I think body_encode() should take a string not a byte array for consistency with the rest of the api (but I'm not positive about this). In quoprimime.body_encode(), body_check() must be passed an int. Current status: 7F (no errors!)
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/quoprimime.py2
-rw-r--r--Lib/email/test/test_email.py17
2 files changed, 9 insertions, 10 deletions
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py
index e59479cbc7..68dc11c695 100644
--- a/Lib/email/quoprimime.py
+++ b/Lib/email/quoprimime.py
@@ -189,7 +189,7 @@ def body_encode(body, maxlinelen=76, eol=NL):
for j in range(linelen):
c = line[j]
prev = c
- if body_check(c):
+ if body_check(ord(c)):
c = quote(c)
elif j+1 == linelen:
# Check for whitespace at end of line; special case
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 15c8325e69..104840ac85 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -2555,7 +2555,6 @@ class TestBase64(unittest.TestCase):
eq(base64mime.body_encode('hello'), 'aGVsbG8=\n')
# Test the binary flag
eq(base64mime.body_encode('hello\n'), 'aGVsbG8K\n')
- eq(base64mime.body_encode('hello\n', 0), 'aGVsbG8NCg==\n')
# Test the maxlinelen arg
eq(base64mime.body_encode('xxxx ' * 20, maxlinelen=40), """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
@@ -2564,7 +2563,8 @@ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
""")
# Test the eol argument
- eq(base64mime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
+ eq(base64mime.body_encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'),
+ """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
@@ -2681,7 +2681,6 @@ class TestQuopri(unittest.TestCase):
eq(quoprimime.body_encode('hello'), 'hello')
# Test the binary flag
eq(quoprimime.body_encode('hello\r\nworld'), 'hello\nworld')
- eq(quoprimime.body_encode('hello\r\nworld', 0), 'hello\nworld')
# Test the maxlinelen arg
eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40), """\
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
@@ -2727,21 +2726,21 @@ class TestCharset(unittest.TestCase):
eq = self.assertEqual
# Try a charset with QP body encoding
c = Charset('iso-8859-1')
- eq('hello w=F6rld', c.body_encode(b'hello w\xf6rld'))
+ eq('hello w=F6rld', c.body_encode('hello w\xf6rld'))
# Try a charset with Base64 body encoding
c = Charset('utf-8')
- eq('aGVsbG8gd29ybGQ=\n', c.body_encode(b'hello world'))
+ eq('aGVsbG8gd29ybGQ=\n', c.body_encode('hello world'))
# Try a charset with None body encoding
c = Charset('us-ascii')
- eq('hello world', c.body_encode(b'hello world'))
+ eq('hello world', c.body_encode('hello world'))
# Try the convert argument, where input codec != output codec
c = Charset('euc-jp')
# With apologies to Tokio Kikuchi ;)
try:
eq('\x1b$B5FCO;~IW\x1b(B',
- c.body_encode(b'\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
+ c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7',
- c.body_encode(b'\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
+ c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
except LookupError:
# We probably don't have the Japanese codecs installed
pass
@@ -2751,7 +2750,7 @@ class TestCharset(unittest.TestCase):
from email import charset as CharsetModule
CharsetModule.add_charset('fake', CharsetModule.QP, None)
c = Charset('fake')
- eq('hello w\xf6rld', c.body_encode(b'hello w\xf6rld'))
+ eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))
def test_unicode_charset_name(self):
charset = Charset('us-ascii')