From e8bedeb45b134e7ae033560353ba064738170cd3 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 7 Aug 2004 16:38:40 +0000 Subject: Resolution of bug #997368, "strftime() backward compatibility". Specifically, time.strftime() no longer accepts a 0 in the yday position of a time tuple, since that can crash some platform strftime() implementations. parsedate_tz(): Change the return value to return 1 in the yday position. Update tests in test_rfc822.py and test_email.py --- Lib/email/_parseaddr.py | 2 +- Lib/email/test/test_email.py | 4 ++-- Lib/rfc822.py | 2 +- Lib/test/test_rfc822.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index 167eb3f..4a31aff 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -116,7 +116,7 @@ def parsedate_tz(data): else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) - tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) + tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) return tuple diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 1749102..4479fb2 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2098,12 +2098,12 @@ class TestMiscellaneous(unittest.TestCase): 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)) + (2003, 2, 25, 13, 47, 26, 0, 1, 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)) + (2003, 2, 5, 13, 47, 26, 0, 1, 0, -28800)) def test_parseaddr_empty(self): self.assertEqual(Utils.parseaddr('<>'), ('', '')) diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 3811a59..3b4246d 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -927,7 +927,7 @@ def parsedate_tz(data): else: tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) - tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) + tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) return tuple diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index c450bf9..491bc8a 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -53,7 +53,7 @@ class MessageTestCase(unittest.TestCase): out = m.getdate('date') if out: self.assertEqual(out, - (1999, 1, 13, 23, 57, 35, 0, 0, 0), + (1999, 1, 13, 23, 57, 35, 0, 1, 0), "date conversion failed") -- cgit v0.12