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_email: test_localtime_daylight_false_dst_true() fails depending on the timezone #79498

Closed
vstinner opened this issue Nov 26, 2018 · 12 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes tests Tests in the Lib/test dir topic-email

Comments

@vstinner
Copy link
Member

BPO 35317
Nosy @warsaw, @vstinner, @bitdancer, @andreas-schwab, @pganssle, @miss-islington, @tirkarthi
PRs
  • bpo-35317: Fix mktime() error in test_email #10721
  • [3.7] bpo-35317: Fix mktime() error in test_email (GH-10721) #10741
  • [3.6] bpo-35317: Fix mktime() error in test_email (GH-10721) #10742
  • Files
  • mktime_bug.py
  • mktime_bug.c
  • 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 2018-11-27.20:30:08.357>
    created_at = <Date 2018-11-26.14:53:28.195>
    labels = ['3.8', '3.7', 'tests', 'expert-email']
    title = 'test_email: test_localtime_daylight_false_dst_true() fails depending on the timezone'
    updated_at = <Date 2019-01-24.11:00:27.023>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-01-24.11:00:27.023>
    actor = 'schwab'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-11-27.20:30:08.357>
    closer = 'vstinner'
    components = ['Tests', 'email']
    creation = <Date 2018-11-26.14:53:28.195>
    creator = 'vstinner'
    dependencies = []
    files = ['47946', '47947']
    hgrepos = []
    issue_num = 35317
    keywords = ['patch']
    message_count = 12.0
    messages = ['330435', '330436', '330437', '330438', '330439', '330441', '330443', '330509', '330514', '330515', '330554', '334291']
    nosy_count = 7.0
    nosy_names = ['barry', 'vstinner', 'r.david.murray', 'schwab', 'p-ganssle', 'miss-islington', 'xtreak']
    pr_nums = ['10721', '10741', '10742']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue35317'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @vstinner
    Copy link
    Member Author

    The two following tests fail on glibc-2.28.9000-19.fc30.x86_64 on Fedora Rawhide depending on the timezone.

    Australia/Lord_Howe: ok
    EDT4: fail
    EST+05EDT,M3.2.0,M11.1.0: ok
    Europe/Kiev: ok
    Europe/Minsk: ok
    MSK-03: fail
    MST+07MDT,M4.1.0,M10.5.0: ok
    STD-1DST,M3.2.0,M11.1.0: ok
    STD-1DST,M4.1.0,M10.1.0: ok
    UTC: fail

    <mock-chroot> sh-4.4# TZ=UTC ./python -m test test_email -m 'test_localtime_daylight_*' -v
    == CPython 3.7.1 (default, Nov 26 2018, 15:33:31) [GCC 8.2.1 20181105 (Red Hat 8.2.1-5)]
    == Linux-4.19.2-301.fc29.x86_64-x86_64-with-fedora-30-Rawhide little-endian
    == cwd: /builddir/Python-3.7.1/build/test_python_9582
    == CPU count: 8
    == encodings: locale=UTF-8, FS=utf-8
    Run tests sequentially
    0:00:00 load avg: 0.33 [1/1] test_email
    test_localtime_daylight_false_dst_false (test.test_email.test_utils.LocaltimeTests) ... ok
    test_localtime_daylight_false_dst_true (test.test_email.test_utils.LocaltimeTests) ... ERROR
    test_localtime_daylight_true_dst_false (test.test_email.test_utils.LocaltimeTests) ... ok
    test_localtime_daylight_true_dst_true (test.test_email.test_utils.LocaltimeTests) ... ERROR

    ======================================================================
    ERROR: test_localtime_daylight_false_dst_true (test.test_email.test_utils.LocaltimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/builddir/Python-3.7.1/Lib/test/test_email/test_utils.py", line 88, in test_localtime_daylight_false_dst_true
        t1 = utils.localtime(t0, isdst=1)
      File "/builddir/Python-3.7.1/Lib/email/utils.py", line 361, in localtime
        seconds = time.mktime(tm)
    OverflowError: mktime argument out of range

    ======================================================================
    ERROR: test_localtime_daylight_true_dst_true (test.test_email.test_utils.LocaltimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/builddir/Python-3.7.1/Lib/test/test_email/test_utils.py", line 81, in test_localtime_daylight_true_dst_true
        t1 = utils.localtime(t0, isdst=1)
      File "/builddir/Python-3.7.1/Lib/email/utils.py", line 361, in localtime
        seconds = time.mktime(tm)
    OverflowError: mktime argument out of range

    Ran 4 tests in 0.007s

    FAILED (errors=2)
    test test_email failed
    test_email failed

    == Tests result: FAILURE ==

    1 test failed:
    test_email

    Total duration: 259 ms
    Tests result: FAILURE

    <mock-chroot> sh-4.4# rpm -q glibc
    glibc-2.28.9000-19.fc30.x86_64
    <mock-chroot> sh-4.4# cat /etc/fedora-release
    Fedora release 30 (Rawhide)
    <mock-chroot> sh-4.4# date
    lun. nov. 26 14:53:14 UTC 2018

    @vstinner vstinner added 3.8 only security fixes tests Tests in the Lib/test dir topic-email labels Nov 26, 2018
    @vstinner
    Copy link
    Member Author

    mktime_bug.py: script to reproduce the bug.

    @tirkarthi
    Copy link
    Member

    I remember some related issues raised in the past about the same test failing on freebsd machines : bpo-31628 and bpo-15750 (some more detail on msg168747)

    @hroncok
    Copy link
    Mannequin

    hroncok mannequin commented Nov 26, 2018

    I found a C reproducer and reported to Fedora glibc tracker: https://bugzilla.redhat.com/show_bug.cgi?id=1653340

    @vstinner
    Copy link
    Member Author

    Miro Hrončok:

    I found a C reproducer and reported to Fedora glibc tracker: https://bugzilla.redhat.com/show_bug.cgi?id=1653340

    Nice, I wrote almost the same one :-) See attached mktime_bug.c:

    $ gcc mktime_bug.c -o mktime_bug
    $ ./mktime_bug 
    TZ=CET: mktime() -> 1331506860, errno=0
    TZ=UTC: mktime() -> 1331514060, errno=0
    
    $ ./mktime_bug
    TZ=CET: mktime() -> 1331506860, errno=0
    TZ=UTC: mktime() -> -1, errno=75

    @vstinner
    Copy link
    Member Author

    I'm able to reproduce the issue on FreeBSD 12.0-RC2:

    vstinner@freebsd$ TZ=CET ./python -m test test_email -m 'test_localtime_daylight_*' -v
    (...)
    Tests result: SUCCESS

    vstinner@freebsd$ TZ=UTC ./python -m test test_email -m 'test_localtime_daylight_*' -v
    (...)
    ======================================================================
    ERROR: test_localtime_daylight_false_dst_true (test.test_email.test_utils.LocaltimeTests)
    ----------------------------------------------------------------------
    (...)
    File "/usr/home/vstinner/prog/python/master/Lib/email/utils.py", line 361, in localtime
    seconds = time.mktime(tm)
    OverflowError: mktime argument out of range

    ======================================================================
    ERROR: test_localtime_daylight_true_dst_true (test.test_email.test_utils.LocaltimeTests)
    ----------------------------------------------------------------------
    (...)
    File "/usr/home/vstinner/prog/python/master/Lib/email/utils.py", line 361, in localtime
    seconds = time.mktime(tm)
    OverflowError: mktime argument out of range

    @vstinner
    Copy link
    Member Author

    Oh, the tests fail since 2012 at least on FreeBSD:

    https://bugs.python.org/issue15750#msg168741

    """
    On the FreeBSD 8.2 build slave:

    ======================================================================
    ERROR: test_localtime_daylight_false_dst_true (test_utils.LocaltimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      (...)
        seconds = time.mktime(tm)
    OverflowError: mktime argument out of range

    ======================================================================
    ERROR: test_localtime_daylight_true_dst_true (test_utils.LocaltimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      (...)
        seconds = time.mktime(tm)
    OverflowError: mktime argument out of range
    """

    bpo-15750 even contains a reproducer in C.

    @vstinner
    Copy link
    Member Author

    New changeset cfaafda by Victor Stinner in branch 'master':
    bpo-35317: Fix mktime() error in test_email (GH-10721)
    cfaafda

    @miss-islington
    Copy link
    Contributor

    New changeset d669154 by Miss Islington (bot) in branch '3.7':
    bpo-35317: Fix mktime() error in test_email (GH-10721)
    d669154

    @miss-islington
    Copy link
    Contributor

    New changeset b59fc31 by Miss Islington (bot) in branch '3.6':
    bpo-35317: Fix mktime() error in test_email (GH-10721)
    b59fc31

    @vstinner
    Copy link
    Member Author

    Python 2.7 doesn't seem to be affected:

    $ TZ=UTC ./python -m test -v test_email
    Tests result: SUCCESS

    @vstinner vstinner added the 3.7 (EOL) end of life label Nov 27, 2018
    @andreas-schwab
    Copy link
    Mannequin

    andreas-schwab mannequin commented Jan 24, 2019

    The test still fails if the timezone database is not available.

    @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
    3.7 (EOL) end of life 3.8 only security fixes tests Tests in the Lib/test dir topic-email
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants