mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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
This commit is contained in:
parent
2c178253bd
commit
e8bedeb45b
4 changed files with 5 additions and 5 deletions
|
|
@ -116,7 +116,7 @@ def parsedate_tz(data):
|
||||||
else:
|
else:
|
||||||
tzsign = 1
|
tzsign = 1
|
||||||
tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60)
|
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
|
return tuple
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2098,12 +2098,12 @@ class TestMiscellaneous(unittest.TestCase):
|
||||||
def test_parsedate_no_dayofweek(self):
|
def test_parsedate_no_dayofweek(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
|
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):
|
def test_parsedate_compact_no_dayofweek(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
|
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):
|
def test_parseaddr_empty(self):
|
||||||
self.assertEqual(Utils.parseaddr('<>'), ('', ''))
|
self.assertEqual(Utils.parseaddr('<>'), ('', ''))
|
||||||
|
|
|
||||||
|
|
@ -927,7 +927,7 @@ def parsedate_tz(data):
|
||||||
else:
|
else:
|
||||||
tzsign = 1
|
tzsign = 1
|
||||||
tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60)
|
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
|
return tuple
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class MessageTestCase(unittest.TestCase):
|
||||||
out = m.getdate('date')
|
out = m.getdate('date')
|
||||||
if out:
|
if out:
|
||||||
self.assertEqual(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")
|
"date conversion failed")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue