diff options
author | Barry Warsaw <barry@python.org> | 2002-06-02 19:08:31 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-06-02 19:08:31 (GMT) |
commit | d2b2e533c050ff135b3cfb14a67dfdbc25c3f1f4 (patch) | |
tree | 08f6fb4527a3fd11b5453b8470d74f6cca750706 /Lib/email | |
parent | 21f77ac0bc38ae54023705feb3e70b0d504dfb13 (diff) | |
download | cpython-d2b2e533c050ff135b3cfb14a67dfdbc25c3f1f4.zip cpython-d2b2e533c050ff135b3cfb14a67dfdbc25c3f1f4.tar.gz cpython-d2b2e533c050ff135b3cfb14a67dfdbc25c3f1f4.tar.bz2 |
header_encode(), encode(): Use _floordiv() from the appropriate
compatibility module.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/base64MIME.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/email/base64MIME.py b/Lib/email/base64MIME.py index aada22d..f177586 100644 --- a/Lib/email/base64MIME.py +++ b/Lib/email/base64MIME.py @@ -27,6 +27,13 @@ import re from binascii import b2a_base64, a2b_base64 from email.Utils import fix_eols +try: + from email._compat22 import _floordiv +except SyntaxError: + # Python 2.1 spells integer division differently + from email._compat21 import _floordiv + + CRLF = '\r\n' NL = '\n' EMPTYSTRING = '' @@ -87,7 +94,7 @@ def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76, # length, after the RFC chrome is added in. base64ed = [] max_encoded = maxlinelen - len(charset) - MISC_LEN - max_unencoded = max_encoded * 3 // 4 + max_unencoded = _floordiv(max_encoded * 3, 4) # BAW: Ben's original code used a step of max_unencoded, but I think it # ought to be max_encoded. Otherwise, where's max_encoded used? I'm @@ -131,7 +138,7 @@ def encode(s, binary=1, maxlinelen=76, eol=NL): s = fix_eols(s) encvec = [] - max_unencoded = maxlinelen * 3 // 4 + max_unencoded = _floordiv(maxlinelen * 3, 4) for i in range(0, len(s), max_unencoded): # BAW: should encode() inherit b2a_base64()'s dubious behavior in # adding a newline to the encoded string? |