changeset: 77562:a283563c8cc4 branch: 2.7 parent: 77537:981ad5254d07 user: Alexander Belopolsky date: Thu Jun 21 20:57:39 2012 -0400 files: Lib/email/_parseaddr.py Lib/email/test/test_email.py Misc/NEWS description: Issue #14653: email.utils.mktime_tz() no longer relies on system mktime() when timezone offest is supplied. diff -r 981ad5254d07 -r a283563c8cc4 Lib/email/_parseaddr.py --- a/Lib/email/_parseaddr.py Thu Jun 21 19:45:19 2012 +0200 +++ b/Lib/email/_parseaddr.py Thu Jun 21 20:57:39 2012 -0400 @@ -13,7 +13,7 @@ 'quote', ] -import time +import time, calendar SPACE = ' ' EMPTYSTRING = '' @@ -150,13 +150,13 @@ def mktime_tz(data): - """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" + """Turn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.""" if data[9] is None: # No zone info, so localtime is better assumption than GMT return time.mktime(data[:8] + (-1,)) else: - t = time.mktime(data[:8] + (0,)) - return t - data[9] - time.timezone + t = calendar.timegm(data) + return t - data[9] def quote(str): diff -r 981ad5254d07 -r a283563c8cc4 Lib/email/test/test_email.py --- a/Lib/email/test/test_email.py Thu Jun 21 19:45:19 2012 +0200 +++ b/Lib/email/test/test_email.py Thu Jun 21 20:57:39 2012 -0400 @@ -2262,6 +2262,12 @@ eq(time.localtime(t)[:6], timetup[:6]) eq(int(time.strftime('%Y', timetup[:9])), 2003) + def test_mktime_tz(self): + self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0, + -1, -1, -1, 0)), 0) + self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0, + -1, -1, -1, 1234)), -1234) + def test_parsedate_y2k(self): """Test for parsing a date with a two-digit year. diff -r 981ad5254d07 -r a283563c8cc4 Misc/NEWS --- a/Misc/NEWS Thu Jun 21 19:45:19 2012 +0200 +++ b/Misc/NEWS Thu Jun 21 20:57:39 2012 -0400 @@ -70,6 +70,9 @@ Library ------- +- Issue #14653: email.utils.mktime_tz() no longer relies on system + mktime() when timezone offest is supplied. + - Issue #15101: Make pool finalizer avoid joining current thread. - Issue #15054: A bug in tokenize.tokenize that caused string literals

AltStyle によって変換されたページ (->オリジナル) /