Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_time failures on AIX #63947

Closed
vstinner opened this issue Nov 24, 2013 · 20 comments
Closed

test_time failures on AIX #63947

vstinner opened this issue Nov 24, 2013 · 20 comments

Comments

@vstinner
Copy link
Member

BPO 19748
Nosy @vstinner, @serhiy-storchaka
Files
  • pylocaltime_aix.patch
  • mktime_aix.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-03-18.11:08:59.347>
    created_at = <Date 2013-11-24.12:36:24.326>
    labels = []
    title = 'test_time failures on AIX'
    updated_at = <Date 2015-03-18.11:08:59.345>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2015-03-18.11:08:59.345>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-18.11:08:59.347>
    closer = 'vstinner'
    components = []
    creation = <Date 2013-11-24.12:36:24.326>
    creator = 'vstinner'
    dependencies = []
    files = ['34130', '34153']
    hgrepos = []
    issue_num = 19748
    keywords = ['patch']
    message_count = 20.0
    messages = ['204201', '204204', '204238', '204363', '211500', '211512', '211587', '211616', '211727', '211728', '211795', '211824', '211825', '211862', '211863', '211866', '211873', '211885', '211887', '238419']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'python-dev', 'serhiy.storchaka', 'David.Edelsohn']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue19748'
    versions = []

    @vstinner
    Copy link
    Member Author

    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

    @vstinner
    Copy link
    Member Author

    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

    @vstinner
    Copy link
    Member Author

    @david: Can you try to check what the minimum accepted timestamp for the time module?

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Nov 25, 2013

    The valid range is 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038.

    @vstinner
    Copy link
    Member Author

    @david Edelsohn: Can you please test attached patch on AIX?

    It should fix test_mktime and test_ctime.

    @serhiy-storchaka
    Copy link
    Member

    Isn't this a duplicate of bpo-11188?

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 19, 2014

    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?

    @vstinner
    Copy link
    Member Author

    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

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 20, 2014

    >>> 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

    @vstinner
    Copy link
    Member Author

    @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.

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 21, 2014

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 21, 2014

    New changeset 502c8b7e8ad2 by Victor Stinner in branch 'default':
    Issue bpo-19748: On AIX, time.mktime() now raises an OverflowError for year
    http://hg.python.org/cpython/rev/502c8b7e8ad2

    @vstinner
    Copy link
    Member Author

    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.

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 21, 2014

    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

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 21, 2014

    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.

    @vstinner
    Copy link
    Member Author

    """
    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

    @DavidEdelsohn
    Copy link
    Mannequin

    DavidEdelsohn mannequin commented Feb 21, 2014

    >>> 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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 21, 2014

    New changeset 00e94e454813 by Victor Stinner in branch 'default':
    Issue bpo-11188, bpo-19748: mktime() returns -1 on error. On Linux, the tm_wday field
    http://hg.python.org/cpython/rev/00e94e454813

    @vstinner
    Copy link
    Member Author

    >>> 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.

    @vstinner
    Copy link
    Member Author

    I'm no more interested to work on this issue, I prefer to close it.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants