From 9cc51f11b72787bc208b58b282cd9888b811c37a Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Thu, 8 May 2003 04:00:05 +0000 Subject: [PATCH] Backporting email 2.5.2 fixes. --- Lib/email/Message.py | 4 ++++ Lib/email/__init__.py | 2 +- Lib/email/_parseaddr.py | 5 ++--- Lib/email/test/test_email.py | 16 +++++++++++++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Lib/email/Message.py b/Lib/email/Message.py index 66f8640eb1f7..0f513f549856 100644 --- a/Lib/email/Message.py +++ b/Lib/email/Message.py @@ -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() diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py index f3916fee3f65..d9462bcab568 100644 --- a/Lib/email/__init__.py +++ b/Lib/email/__init__.py @@ -4,7 +4,7 @@ """A package for parsing, handling, and generating email messages. """ -__version__ = '2.5.1' +__version__ = '2.5.2' __all__ = [ 'base64MIME', diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index 2b28b6430488..c56cfd03cf35 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -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: diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 280b400161ca..a0586e51360a 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -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: , - +\t List: List-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('<>')), '') -- 2.47.3