Mailing List Archive

python/dist/src/Lib/email Message.py,1.21,1.22
Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv24094

Modified Files:
Message.py
Log Message:
_formatparam(), set_param(): RFC 2231 encoding support by Oleg
Broytmann in SF patch #600096. Specifically, the former function now
encodes the triplets, while the latter adds optional charset and
language arguments.


Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Message.py 6 Sep 2002 03:38:12 -0000 1.21
--- Message.py 6 Sep 2002 03:55:04 -0000 1.22
***************
*** 39,44 ****
# instance.
if isinstance(value, TupleType):
! # Convert to ascii, ignore language
! value = unicode(value[2], value[0]).encode("ascii")
# BAW: Please check this. I think that if quote is set it should
# force quoting even if not necessary.
--- 39,45 ----
# instance.
if isinstance(value, TupleType):
! # Encode as per RFC 2231
! param += '*'
! value = Utils.encode_rfc2231(value[2], value[0], value[1])
# BAW: Please check this. I think that if quote is set it should
# force quoting even if not necessary.
***************
*** 544,548 ****
return failobj

! def set_param(self, param, value, header='Content-Type', requote=1):
"""Set a parameter in the Content-Type: header.

--- 545,550 ----
return failobj

! def set_param(self, param, value, header='Content-Type', requote=1,
! charset=None, language=''):
"""Set a parameter in the Content-Type: header.

***************
*** 557,561 ****
--- 559,569 ----
all parameters will be quoted as appropriate unless requote is
set to a false value.
+
+ If charset is specified the parameter will be encoded according to RFC
+ 2231. In this case language is optional.
"""
+ if not isinstance(value, TupleType) and charset:
+ value = (charset, language, value)
+
if not self.has_key(header) and header.lower() == 'content-type':
ctype = 'text/plain'