]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backporting email 2.5.2 fixes.
authorBarry Warsaw <barry@python.org>
Thu, 8 May 2003 04:00:05 +0000 (04:00 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 8 May 2003 04:00:05 +0000 (04:00 +0000)
Lib/email/Message.py
Lib/email/__init__.py
Lib/email/_parseaddr.py
Lib/email/test/test_email.py

index 66f8640eb1f7459434f59de7051da0deb9a94b0f..0f513f5498560685e184fbda0955317a27ee1a13 100644 (file)
@@ -102,6 +102,10 @@ class Message:
         """Return the entire formatted message as a string.
         Optional `unixfrom' when True, means include the Unix From_ envelope
         header.
+
+        This is a convenience method and may not generate the message exactly
+        as you intend.  For more flexibility, use the flatten() method of a
+        Generator instance.
         """
         from email.Generator import Generator
         fp = StringIO()
index f3916fee3f65fc05d1f14a6fe49b56851822a882..d9462bcab568977675184c66a78419a5acad3e5a 100644 (file)
@@ -4,7 +4,7 @@
 """A package for parsing, handling, and generating email messages.
 """
 
-__version__ = '2.5.1'
+__version__ = '2.5.2'
 
 __all__ = [
     'base64MIME',
index 2b28b64304887b7ffcf63477ba22f28f4cead807..c56cfd03cf3569feaf8d90a224694b5f5fab62a4 100644 (file)
@@ -54,9 +54,8 @@ def parsedate_tz(data):
         del data[0]
     else:
         i = data[0].rfind(',')
-        if i < 0:
-            return None
-        data[0] = data[0][i+1:]
+        if i >= 0:
+            data[0] = data[0][i+1:]
     if len(data) == 3: # RFC 850 date, deprecated
         stuff = data[0].split('-')
         if len(stuff) == 3:
index 280b400161caa3c01992f83bbcd65221c3d919f7..a0586e51360ada1bd9f58678cecb04d60b6ed11d 100644 (file)
@@ -833,11 +833,11 @@ Face-2: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
         eq = self.ndiffAssertEqual
         m = '''\
 Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905);
-       Wed, 16 Oct 2002 07:41:11 -0700'''
+\tWed, 16 Oct 2002 07:41:11 -0700'''
         msg = email.message_from_string(m)
         eq(msg.as_string(), '''\
 Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
-       Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700
+\tMicrosoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700
 
 ''')
 
@@ -851,7 +851,7 @@ List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-tal
         msg['List'] = Header(h, header_name='List')
         eq(msg.as_string(), """\
 List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
-       <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
+\t<mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
 List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
  <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
 
@@ -1868,6 +1868,16 @@ class TestMiscellaneous(unittest.TestCase):
         self.assertEqual(Utils.parsedate('Wed,3 Apr 2002 14:58:26 +0800'),
                          Utils.parsedate('Wed, 3 Apr 2002 14:58:26 +0800'))
 
+    def test_parsedate_no_dayofweek(self):
+        eq = self.assertEqual
+        eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
+           (2003, 2, 25, 13, 47, 26, 0, 0, 0, -28800))
+
+    def test_parsedate_compact_no_dayofweek(self):
+        eq = self.assertEqual
+        eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
+           (2003, 2, 5, 13, 47, 26, 0, 0, 0, -28800))
+
     def test_parseaddr_empty(self):
         self.assertEqual(Utils.parseaddr('<>'), ('', ''))
         self.assertEqual(Utils.formataddr(Utils.parseaddr('<>')), '')