Looks like a real python bug, and has been reported upstream by Anthony Baxter on 2006-03-19 (see URL field). Even if this is resolved as upstream (and the test left enabled unconditionally), it's my hope that anyone else encountering this problem will find this bug and know they're not alone :-) I'm seeing it on all my TZ=Australia/Melbourne machines, but we're not in Daylight Savings Time (DST) at present. "sudo env TZ=UTC emerge python" works fine, but when TZ is left at Australia/Melbourne the test phase fails with: "test_set_param (email.test.test_email.TestRFC2231) ... ok ====================================================================== FAIL: test_parsedate_acceptable_to_time_functions (email.test.test_email.TestMiscellaneous) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email/test/test_email.py", line 2124, in test_parsedate_acceptable_to_time_functions eq(time.localtime(t)[:6], timetup[:6]) AssertionError: (2003, 2, 5, 14, 47, 26) != (2003, 2, 5, 13, 47, 26) ---------------------------------------------------------------------- Ran 226 tests in 0.513s FAILED (failures=1) test test_email failed -- Traceback (most recent call last): File "/var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email/test/test_email.py", line 2124, in test_parsedate_acceptable_to_time_functions eq(time.localtime(t)[:6], timetup[:6]) AssertionError: (2003, 2, 5, 14, 47, 26) != (2003, 2, 5, 13, 47, 26) make: *** [test] Error 1 !!! ERROR: dev-lang/python-2.4.3-r1 failed. Call stack: ebuild.sh, line 1539: Called dyn_test ebuild.sh, line 987: Called src_test python-2.4.3-r1.ebuild, line 285: Called die"
the fact it hasn't been solved sicne 2003 might mean it is not a bug with python. so tell me what happens here: TZ="Australia/Melbourne" python -c 'import time; print time.localtime()' TZ="Australia/Melbourne" date Are they printing out the same time?
Yes, they are (down to the second). However, the 2003 is dummy/test data, as seen in test_email.py: def test_parsedate_acceptable_to_time_functions(self): eq = self.assertEqual timetup = Utils.parsedate('5 Feb 2003 13:47:26 -0800') t = int(time.mktime(timetup)) eq(time.localtime(t)[:6], timetup[:6]) FYI the particular date being tested is within our usual daylight savings period, where we are GMT +11 instead of GMT +10.
Looks like time.localtime is working correctly: aross@gentoo ~ $ date -d '5 Feb 2003 13:47:26 -0800' -u Wed Feb 5 21:47:26 UTC 2003 aross@gentoo ~ $ date -d '5 Feb 2003 13:47:26 -0800' Thu Feb 6 08:47:26 EST 2003 aross@gentoo ~ $ date -d '5 Feb 2003 13:47:26 -0800' +%s 1044481646 aross@gentoo ~ $ python -c 'import time; print time.localtime(1044481646)' (2003, 2, 6, 8, 47, 26, 3, 37, 1) However, parsedate uses parsedate_tz for the heavy lifting, then throws away the UTC offset: aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ python -c 'import Utils; print Utils.parsedate_tz("5 Feb 2003 13:47:26 -0800")' (2003, 2, 5, 13, 47, 26, 0, 1, 0, -28800) aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ python -c 'import Utils; print Utils.parsedate("5 Feb 2003 13:47:26 -0800")' (2003, 2, 5, 13, 47, 26, 0, 1, 0) The effect of TZ is best demonstrated here: aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ python -c 'import Utils; import time; print time.localtime(time.mktime(Utils.parsedate_tz("5 Feb 2003 13:47:26 -0800")[:9]))' (2003, 2, 5, 14, 47, 26, 2, 36, 1) aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ TZ=UTC python -c 'import Utils; import time; print time.localtime(time.mktime(Utils.parsedate_tz("5 Feb 2003 13:47:26 -0800")[:9]))' (2003, 2, 5, 13, 47, 26, 2, 36, 0) If the month is changed to June (when DST is NOT in effect, putting us back at GMT+10), everything works as expected: aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ TZ=UTC python -c 'import Utils; import time; print time.localtime(time.mktime(Utils.parsedate_tz("5 June 2003 13:47:26 -0800")[:9]))' (2003, 6, 5, 13, 47, 26, 3, 156, 0) aross@gentoo /var/tmp/portage/python-2.4.3-r1/work/Python-2.4.3/Lib/email $ python -c 'import Utils; import time; print time.localtime(time.mktime(Utils.parsedate_tz("5 June 2003 13:47:26 -0800")[:9]))' (2003, 6, 5, 13, 47, 26, 3, 156, 0) It should be possible for others to replicate these results by setting TZ=Australia/Melbourne.
Can't reproduce this in 2.4.4.