Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 144798 - dev-lang/python-2.4.3 with TZ=Australia/Melbourne fails test
Summary: dev-lang/python-2.4.3 with TZ=Australia/Melbourne fails test
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Python Gentoo Team
URL: https://sourceforge.net/tracker/?func...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-22 17:01 UTC by Andrew Ross (RETIRED)
Modified: 2007-05-07 07:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Ross (RETIRED) gentoo-dev 2006-08-22 17:01:12 UTC
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"
Comment 1 Alastair Tse (RETIRED) gentoo-dev 2006-08-23 02:31:29 UTC
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?
Comment 2 Andrew Ross (RETIRED) gentoo-dev 2006-08-23 20:21:31 UTC
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. 
Comment 3 Andrew Ross (RETIRED) gentoo-dev 2006-08-23 20:40:37 UTC
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.
Comment 4 Bryan Østergaard (RETIRED) gentoo-dev 2007-05-07 07:51:59 UTC
Can't reproduce this in 2.4.4.