[Python-checkins] r42227 - in python/branches/release23-maint/Lib/email: _parseaddr.py test/test_email.py

barry.warsaw python-checkins at python.org
Fri Feb 3 05:41:25 CET 2006


Author: barry.warsaw
Date: Fri Feb  3 05:41:24 2006
New Revision: 42227

Modified:
   python/branches/release23-maint/Lib/email/_parseaddr.py
   python/branches/release23-maint/Lib/email/test/test_email.py
Log:
parsedate_tz(): Return a 1 in the tm_yday field so that the value is
acceptable to Python 2.4's time.strftime().  This fix mirrors the behavior in
email 3.0.  That field is documented as being "not useable" so it might as
well not be buggy too <wink>.

Add a test for this behavior and update a few tests that were expecting a 0 in
this field.  After committing I will run the entire Python 2.3 test suite to
ensure this doesn't break any Python tests.


Modified: python/branches/release23-maint/Lib/email/_parseaddr.py
==============================================================================
--- python/branches/release23-maint/Lib/email/_parseaddr.py	(original)
+++ python/branches/release23-maint/Lib/email/_parseaddr.py	Fri Feb  3 05:41:24 2006
@@ -1,4 +1,4 @@
-# Copyright (C) 2002 Python Software Foundation
+# Copyright (C) 2002-2006 Python Software Foundation
 
 """Email address parsing code.
 
@@ -123,8 +123,7 @@
         else:
             tzsign = 1
         tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60)
-    tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset)
-    return tuple
+    return yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset
 
 
 def parsedate(data):

Modified: python/branches/release23-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release23-maint/Lib/email/test/test_email.py	(original)
+++ python/branches/release23-maint/Lib/email/test/test_email.py	Fri Feb  3 05:41:24 2006
@@ -1949,12 +1949,21 @@
     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_parsedate_acceptable_to_time_functions(self):
+        eq = self.assertEqual
+        timetup = Utils.parsedate('5 Feb 2003 13:47:26 -0800')
+        eq(int(time.mktime(timetup)), 1044470846)
+        eq(int(time.strftime('%Y', timetup)), 2003)
+        timetup = Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
+        eq(int(time.mktime(timetup[:9])), 1044470846)
+        eq(int(time.strftime('%Y', timetup[:9])), 2003)
 
     def test_parseaddr_empty(self):
         self.assertEqual(Utils.parseaddr('<>'), ('', ''))


More information about the Python-checkins mailing list