CVS: tmda/TMDA/pythonlib/email Message.py,1.6,1.7 Utils.py,1.5,1.6 __init__.py,1.11,1.12

"Jason R. Mastaler" <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/TMDA/pythonlib/email
In directory sc8-pr-cvs1:/tmp/cvs-serv27966/TMDA/pythonlib/email

Modified Files:
	Message.py Utils.py __init__.py 
Log Message:
sync with email v2.5.4

Index: Message.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/pythonlib/email/Message.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Message.py	10 Jun 2003 17:23:23 -0000	1.6
+++ Message.py	19 Aug 2003 18:53:15 -0000	1.7
@@ -571,13 +571,16 @@
         Parameter keys are always compared case insensitively.  The return
         value can either be a string, or a 3-tuple if the parameter was RFC
         2231 encoded.  When it's a 3-tuple, the elements of the value are of
-        the form (CHARSET, LANGUAGE, VALUE), where LANGUAGE may be the empty
-        string.  Your application should be prepared to deal with these, and
-        can convert the parameter to a Unicode string like so:
+        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
+        LANGUAGE can be None, in which case you should consider VALUE to be
+        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
+
+        Your application should be prepared to deal with 3-tuple return
+        values, and can convert the parameter to a Unicode string like so:
 
             param = msg.get_param('foo')
             if isinstance(param, tuple):
-                param = unicode(param[2], param[0])
+                param = unicode(param[2], param[0] or 'us-ascii')
 
         In any case, the parameter value (either the returned string, or the
         VALUE item in the 3-tuple) is always unquoted, unless unquote is set
@@ -708,7 +711,7 @@
         if isinstance(filename, TupleType):
             # It's an RFC 2231 encoded parameter
             newvalue = _unquotevalue(filename)
-            return unicode(newvalue[2], newvalue[0])
+            return unicode(newvalue[2], newvalue[0] or 'us-ascii')
         else:
             newvalue = _unquotevalue(filename.strip())
             return newvalue
@@ -725,7 +728,8 @@
             return failobj
         if isinstance(boundary, TupleType):
             # RFC 2231 encoded, so decode.  It better end up as ascii
-            return unicode(boundary[2], boundary[0]).encode('us-ascii')
+            charset = boundary[0] or 'us-ascii'
+            return unicode(boundary[2], charset).encode('us-ascii')
         return _unquotevalue(boundary.strip())
 
     def set_boundary(self, boundary):
@@ -792,7 +796,8 @@
             return failobj
         if isinstance(charset, TupleType):
             # RFC 2231 encoded, so decode it, and it better end up as ascii.
-            charset = unicode(charset[2], charset[0]).encode('us-ascii')
+            pcharset = charset[0] or 'us-ascii'
+            charset = unicode(charset[2], pcharset).encode('us-ascii')
         # RFC 2046, $4.1.2 says charsets are not case sensitive
         return charset.lower()
 

Index: Utils.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/pythonlib/email/Utils.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Utils.py	11 Mar 2003 20:39:02 -0000	1.5
+++ Utils.py	19 Aug 2003 18:53:15 -0000	1.6
@@ -280,7 +280,7 @@
     import urllib
     parts = s.split("'", 2)
     if len(parts) == 1:
-        return None, None, s
+        return None, None, urllib.unquote(s)
     charset, language, s = parts
     return charset, language, urllib.unquote(s)
 

Index: __init__.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/pythonlib/email/__init__.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- __init__.py	3 Jun 2003 00:32:44 -0000	1.11
+++ __init__.py	19 Aug 2003 18:53:15 -0000	1.12
@@ -4,7 +4,7 @@
 """A package for parsing, handling, and generating email messages.
 """
 
-__version__ = '2.5.3'
+__version__ = '2.5.4'
 
 __all__ = [
     'base64MIME',

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.