[Python-checkins] r42077 - in python/branches/release24-maint/Lib/email: Message.py __init__.py test/data/msg_44.txt test/test_email.py

barry.warsaw python-checkins at python.org
Tue Jan 17 06:09:20 CET 2006


Author: barry.warsaw
Date: Tue Jan 17 06:09:19 2006
New Revision: 42077

Added:
   python/branches/release24-maint/Lib/email/test/data/msg_44.txt
      - copied unchanged from r42076, python/trunk/Lib/email/test/data/msg_44.txt
Modified:
   python/branches/release24-maint/Lib/email/Message.py
   python/branches/release24-maint/Lib/email/__init__.py
   python/branches/release24-maint/Lib/email/test/test_email.py
Log:
Ported 42076 from the trunk.

SF bug #1403349 solution for email 3.0; some MUAs use the 'file' parameter
name in the Content-Distribution header, so Message.get_filename() should fall
back to using that.

Also, bump the email package version to 3.0.1 for eventual release.  Of
course, add a test case too.

XXX Need to update the documentation.


Modified: python/branches/release24-maint/Lib/email/Message.py
==============================================================================
--- python/branches/release24-maint/Lib/email/Message.py	(original)
+++ python/branches/release24-maint/Lib/email/Message.py	Tue Jan 17 06:09:19 2006
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2004 Python Software Foundation
+# Copyright (C) 2001-2006 Python Software Foundation
 # Author: Barry Warsaw
 # Contact: email-sig at python.org
 
@@ -701,11 +701,15 @@
         """Return the filename associated with the payload if present.
 
         The filename is extracted from the Content-Disposition header's
-        `filename' parameter, and it is unquoted.
+        `filename' parameter, and it is unquoted.  If that header is missing
+        the `filename' parameter, this method falls back to looking for the
+        `name' parameter.
         """
         missing = object()
         filename = self.get_param('filename', missing, 'content-disposition')
         if filename is missing:
+            filename = self.get_param('name', missing, 'content-disposition')
+        if filename is missing:
             return failobj
         return Utils.collapse_rfc2231_value(filename).strip()
 

Modified: python/branches/release24-maint/Lib/email/__init__.py
==============================================================================
--- python/branches/release24-maint/Lib/email/__init__.py	(original)
+++ python/branches/release24-maint/Lib/email/__init__.py	Tue Jan 17 06:09:19 2006
@@ -1,10 +1,10 @@
-# Copyright (C) 2001-2004 Python Software Foundation
+# Copyright (C) 2001-2006 Python Software Foundation
 # Author: Barry Warsaw
 # Contact: email-sig at python.org
 
 """A package for parsing, handling, and generating email messages."""
 
-__version__ = '3.0+'
+__version__ = '3.0.1'
 
 __all__ = [
     'base64MIME',

Modified: python/branches/release24-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release24-maint/Lib/email/test/test_email.py	(original)
+++ python/branches/release24-maint/Lib/email/test/test_email.py	Tue Jan 17 06:09:19 2006
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2004 Python Software Foundation
+# Copyright (C) 2001-2006 Python Software Foundation
 # Contact: email-sig at python.org
 # email package unit tests
 
@@ -147,6 +147,13 @@
         subpart = msg.get_payload(1)
         eq(subpart.get_filename(), 'dingusfish.gif')
 
+    def test_get_filename_with_name_parameter(self):
+        eq = self.assertEqual
+
+        msg = self._msgobj('msg_44.txt')
+        filenames = [p.get_filename() for p in msg.get_payload()]
+        eq(filenames, ['msg.txt', 'msg.txt'])
+
     def test_get_boundary(self):
         eq = self.assertEqual
         msg = self._msgobj('msg_07.txt')


More information about the Python-checkins mailing list