Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08bc84c

Browse files
committed
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 inemail 3.0. That field is documented as being "not useable" so it might aswell not be buggy too <wink>.Add a test for this behavior and update a few tests that were expecting a 0 inthis field. After committing I will run the entire Python 2.3 test suite toensure this doesn't break any Python tests.
1 parent9b55f08 commit08bc84c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎Lib/email/_parseaddr.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002 Python Software Foundation
1+
# Copyright (C) 2002-2006 Python Software Foundation
22

33
"""Email address parsing code.
44
@@ -123,8 +123,7 @@ def parsedate_tz(data):
123123
else:
124124
tzsign=1
125125
tzoffset=tzsign* ( (tzoffset/100)*3600+ (tzoffset%100)*60)
126-
tuple= (yy,mm,dd,thh,tmm,tss,0,0,0,tzoffset)
127-
returntuple
126+
returnyy,mm,dd,thh,tmm,tss,0,1,0,tzoffset
128127

129128

130129
defparsedate(data):

‎Lib/email/test/test_email.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,12 +1949,21 @@ def test_parsedate_compact(self):
19491949
deftest_parsedate_no_dayofweek(self):
19501950
eq=self.assertEqual
19511951
eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
1952-
(2003,2,25,13,47,26,0,0,0,-28800))
1952+
(2003,2,25,13,47,26,0,1,0,-28800))
19531953

19541954
deftest_parsedate_compact_no_dayofweek(self):
19551955
eq=self.assertEqual
19561956
eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
1957-
(2003,2,5,13,47,26,0,0,0,-28800))
1957+
(2003,2,5,13,47,26,0,1,0,-28800))
1958+
1959+
deftest_parsedate_acceptable_to_time_functions(self):
1960+
eq=self.assertEqual
1961+
timetup=Utils.parsedate('5 Feb 2003 13:47:26 -0800')
1962+
eq(int(time.mktime(timetup)),1044470846)
1963+
eq(int(time.strftime('%Y',timetup)),2003)
1964+
timetup=Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
1965+
eq(int(time.mktime(timetup[:9])),1044470846)
1966+
eq(int(time.strftime('%Y',timetup[:9])),2003)
19581967

19591968
deftest_parseaddr_empty(self):
19601969
self.assertEqual(Utils.parseaddr('<>'), ('',''))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp