classification
Title: test_time failures on AIX
Type: Stage:
Components: Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: David.Edelsohn, haypo, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-11-24 12:36 by haypo, last changed 2015-03-18 11:08 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
pylocaltime_aix.patch haypo, 2014-02-18 09:19 review
mktime_aix.patch haypo, 2014-02-20 15:12 review
Messages (20)
msg204201 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-11-24 12:36
http://buildbot.python.org/all/builders/PPC64%20AIX%203.x/builds/1138/steps/test/logs/stdio

======================================================================
ERROR: test_mktime (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/test_time.py", line 348, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range

======================================================================
FAIL: test_ctime (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/test_time.py", line 233, in test_ctime
    self.assertEqual(time.ctime(testval)[20:], str(year))
AssertionError: '1941' != '-100'
- 1941
+ -100
msg204204 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-11-24 12:45
Oh, I missed also this one:



======================================================================
FAIL: test_mktime_error (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shager/cpython-buildarea/3.x.edelsohn-aix-ppc64/build/Lib/test/test_time.py", line 365, in test_mktime_error
    self.assertEqual(time.strftime('%Z', tt), tzname)
AssertionError: 'LMT' != 'PST'
- LMT
+ PST
msg204238 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-11-24 17:35
@David: Can you try to check what the minimum accepted timestamp for the time module?
msg204363 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-11-25 17:00
The valid range is 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038.
msg211500 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-18 09:19
@David Edelsohn: Can you please test attached patch on AIX?

It should fix test_mktime and test_ctime.
msg211512 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-18 13:03
Isn't this a duplicate of issue11188?
msg211587 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-19 01:50
With the patch, the results are:

ERROR: test_ctime (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/src/cpython/Lib/test/test_time.py", line 239, in test_ctime
    self.assertEqual(time.ctime(testval)[20:], str(year))
OverflowError: ctime() timestamp argument out of range

======================================================================
FAIL: test_mktime_error (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/src/cpython/Lib/test/test_time.py", line 371, in test_mktime_error
    self.assertEqual(time.strftime('%Z', tt), tzname)
AssertionError: 'LMT' != 'PST'
- LMT
+ PST

which is what I would expect based on the patch and the new AIX-specific error message. What did you expect?
msg211616 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-19 13:35
> which is what I would expect based on the patch and the new AIX-specific error message. What did you expect?

No, mktime() and ctime() should both raise OverflowError. It looks like mktime() doesn't fail. Can you please try the following examples on AIX?

Examples on Linux:

>>> time.mktime((-100, 1, 10) + (0,)*6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: year out of range
>>> time.mktime((100, 1, 10) + (0,)*6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: year out of range
>>> time.mktime((1900, 1, 10) + (0,)*6)
-2208211761.0
>>> time.mktime((1930, 1, 10) + (0,)*6)
-1261526400.0
>>> time.mktime((1969,12,31, 23,59,59, 0,0,0))
-3601.0
msg211727 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-20 14:57
>>> time.mktime((-100, 1, 10) + (0,)*6)
-897577382.0
>>> time.mktime((100, 1, 10) + (0,)*6)
1118888922.0
>>> time.mktime((1900, 1, 10) + (0,)*6)
2086784896.0
>>> time.mktime((1930, 1, 10) + (0,)*6)
-1261497600.0
>>> time.mktime((1969,12,31, 23,59,59, 0,0,0))
28799.0
msg211728 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-20 15:12
@David Edelsohn: Oh nice, mktime() has an integer overflow on AIX. Could you please try to apply attached mktime_aix.patch, run test_time and try again my examples of msg211616? Thanks.
msg211795 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-21 03:12
With the latest patch, test_time passes.

>>> time.mktime((-100, 1, 10) + (0,)*6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>> time.mktime((-100, 1, 10) + (0,)*6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>> time.mktime((1900, 1, 10) + (0,)*6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>> time.mktime((1930, 1, 10) + (0,)*6)
-1261497600.0
>>> time.mktime((1969,12,31, 23,59,59, 0,0,0))
28799.0
msg211824 - (view) Author: Roundup Robot (python-dev) Date: 2014-02-21 08:28
New changeset 502c8b7e8ad2 by Victor Stinner in branch 'default':
Issue #19748: On AIX, time.mktime() now raises an OverflowError for year
http://hg.python.org/cpython/rev/502c8b7e8ad2
msg211825 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-21 08:32
> With the latest patch, test_time passes.

Ok, thanks for your tests. But time.ctime() is still wrong. Can you please try the following examples with the latest Python version (502c8b7e8ad2) and then retry with pylocaltime_aix.patch?

>>> time.ctime(-2**29)
'Sat Dec 27 06:11:28 1952'
>>> time.ctime(2**29)
'Mon Jan  5 19:48:32 1987'

I would like to know if pylocaltime_aix.patch is needed or not.
msg211862 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-21 14:47
WITHOUT the patch to timemodule.c:

>>> time.ctime(-2**29)
'Fri Dec 26 21:11:28 1952'
>>> time.ctime(2**29)
'Mon Jan  5 10:48:32 1987'

ERROR: test_mktime (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/src/cpython/Lib/test/test_time.py", line 354, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range
msg211863 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-21 14:51
WITH the patch:

>>> time.ctime(-2**29)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: ctime() timestamp argument out of range
>>> time.ctime(2**29)
'Mon Jan  5 10:48:32 1987'

OK (skipped=8)
1 test OK.
msg211866 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-21 15:33
"""
WITHOUT the patch to timemodule.c:

>>> time.ctime(-2**29)
'Fri Dec 26 21:11:28 1952'
"""

Oh, in this case, pylocaltime_aix.patch is wrong. There was a bug in mktime(), but ctime() works fine.

"""
  File "/home/dje/src/cpython/Lib/test/test_time.py", line 354, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range
"""

Oh, I don't understand this one. On Linux I get:

>>> time.localtime(-2)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=59, tm_sec=58, tm_wday=3, tm_yday=1, tm_isdst=0)
>>> time.localtime(-1)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=59, tm_sec=59, tm_wday=3, tm_yday=1, tm_isdst=0)
>>> time.localtime(0)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=1, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)
>>> time.localtime(1)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=1, tm_min=0, tm_sec=1, tm_wday=3, tm_yday=1, tm_isdst=0)

And:

>>> time.mktime(time.localtime(-2)) 
-2.0
>>> time.mktime(time.localtime(-1)) 
-1.0
>>> time.mktime(time.localtime(0)) 
0.0
>>> time.mktime(time.localtime(1)) 
1.0
msg211873 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2014-02-21 18:32
>>> time.localtime(-2)
time.struct_time(tm_year=1969, tm_mon=12, tm_mday=31, tm_hour=15, tm_min=59, tm_sec=58, tm_wday=2, tm_yday=365, tm_isdst=0)
>>> time.localtime(-1)
time.struct_time(tm_year=1969, tm_mon=12, tm_mday=31, tm_hour=15, tm_min=59, tm_sec=59, tm_wday=2, tm_yday=365, tm_isdst=0)
>>> time.localtime(0)
time.struct_time(tm_year=1969, tm_mon=12, tm_mday=31, tm_hour=16, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=365, tm_isdst=0)
>>> time.localtime(1)
time.struct_time(tm_year=1969, tm_mon=12, tm_mday=31, tm_hour=16, tm_min=0, tm_sec=1, tm_wday=2, tm_yday=365, tm_isdst=0)
>>> time.mktime(time.localtime(-2))
-2.0
>>> time.mktime(time.localtime(-1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range
>>> time.mktime(time.localtime(0))
0.0
>>> time.mktime(time.localtime(1))
1.0
msg211885 - (view) Author: Roundup Robot (python-dev) Date: 2014-02-21 22:54
New changeset 00e94e454813 by Victor Stinner in branch 'default':
Issue #11188, #19748: mktime() returns -1 on error. On Linux, the tm_wday field
http://hg.python.org/cpython/rev/00e94e454813
msg211887 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-02-21 22:57
>>> time.mktime(time.localtime(-1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range

Oh yes, I now remember it. Sorry, it was 3 years ago:
http://bugs.python.org/issue11188#msg128541

The problem is to detect invalid time tuple and support the timestamp value -1 (1 second before the UNIX epoch).

I modified the test to skip mktime(localtime(-1)) test on AIX: changeset 00e94e454813.

It would be nice to support this specific value, but I don't see how to implement it. It's maybe not possible.
msg238419 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2015-03-18 11:08
I'm no more interested to work on this issue, I prefer to close it.
History
Date User Action Args
2015-03-18 11:08:59hayposetstatus: open -> closed
resolution: out of date
messages: + msg238419
2014-02-21 22:57:08hayposetmessages: + msg211887
2014-02-21 22:54:58python-devsetmessages: + msg211885
2014-02-21 18:32:49David.Edelsohnsetmessages: + msg211873
2014-02-21 15:33:40hayposetmessages: + msg211866
2014-02-21 14:51:51David.Edelsohnsetmessages: + msg211863
2014-02-21 14:47:02David.Edelsohnsetmessages: + msg211862
2014-02-21 08:32:54hayposetmessages: + msg211825
2014-02-21 08:28:11python-devsetnosy: + python-dev
messages: + msg211824
2014-02-21 03:12:34David.Edelsohnsetmessages: + msg211795
2014-02-20 15:12:23hayposetfiles: + mktime_aix.patch

messages: + msg211728
2014-02-20 14:57:34David.Edelsohnsetmessages: + msg211727
2014-02-19 13:35:57hayposetmessages: + msg211616
2014-02-19 01:50:46David.Edelsohnsetmessages: + msg211587
2014-02-18 13:03:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg211512
2014-02-18 09:19:20hayposetfiles: + pylocaltime_aix.patch
keywords: + patch
messages: + msg211500
2013-11-25 17:00:20David.Edelsohnsetmessages: + msg204363
2013-11-24 17:35:14hayposetmessages: + msg204238
2013-11-24 12:45:07hayposetmessages: + msg204204
2013-11-24 12:36:24haypocreate