[Python-checkins] CVS: python/dist/src/Lib/email Utils.py,1.8,1.9
Barry Warsaw
bwarsaw@users.sourceforge.net
Mon, 03 Dec 2001 11:26:42 -0800
Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv15267
Modified Files:
Utils.py
Log Message:
decode(), encode(): Accepting the minor optimizations from SF patch
#486375, but not the rest of it, since that changes the documented
semantics of encode().
Index: Utils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Utils.py 2001/11/19 18:36:43 1.8
--- Utils.py 2001/12/03 19:26:40 1.9
***************
*** 76,87 ****
rtn.append(parts[0])
charset = parts[1]
! encoding = parts[2]
atom = parts[3]
# The next chunk to decode should be in parts[4]
parts = ecre.split(parts[4])
# The encoding must be either `q' or `b', case-insensitive
! if encoding.lower() == 'q':
func = _qdecode
! elif encoding.lower() == 'b':
func = _bdecode
else:
--- 76,87 ----
rtn.append(parts[0])
charset = parts[1]
! encoding = parts[2].lower()
atom = parts[3]
# The next chunk to decode should be in parts[4]
parts = ecre.split(parts[4])
# The encoding must be either `q' or `b', case-insensitive
! if encoding == 'q':
func = _qdecode
! elif encoding == 'b':
func = _bdecode
else:
***************
*** 97,107 ****
def encode(s, charset='iso-8859-1', encoding='q'):
"""Encode a string according to RFC 2047."""
! if encoding.lower() == 'q':
estr = _qencode(s)
! elif encoding.lower() == 'b':
estr = _bencode(s)
else:
raise ValueError, 'Illegal encoding code: ' + encoding
! return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr)
--- 97,108 ----
def encode(s, charset='iso-8859-1', encoding='q'):
"""Encode a string according to RFC 2047."""
! encoding = encoding.lower()
! if encoding == 'q':
estr = _qencode(s)
! elif encoding == 'b':
estr = _bencode(s)
else:
raise ValueError, 'Illegal encoding code: ' + encoding
! return '=?%s?%s?%s?=' % (charset.lower(), encoding, estr)