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

'%Z' strftime specifier never works with musl #78853

Closed
benjaminp opened this issue Sep 14, 2018 · 5 comments
Closed

'%Z' strftime specifier never works with musl #78853

benjaminp opened this issue Sep 14, 2018 · 5 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@benjaminp
Copy link
Contributor

BPO 34672
Nosy @abalkin, @benjaminp, @zhangyangyu, @pganssle
PRs
  • bpo-34672: Try to pass the C library's own timezone strings back to it. #9288
  • bpo-34672: Don't pass NULL to gmtime_r. #9312
  • bpo-34672: fix a compiler warning in timemodule.c #10176
  • 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 2022-01-15.20:08:32.877>
    created_at = <Date 2018-09-14.04:01:29.001>
    labels = ['3.8', '3.7', 'library']
    title = "'%Z' strftime specifier never works with musl"
    updated_at = <Date 2022-01-15.20:08:32.876>
    user = 'https://github.com/benjaminp'

    bugs.python.org fields:

    activity = <Date 2022-01-15.20:08:32.876>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-01-15.20:08:32.877>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2018-09-14.04:01:29.001>
    creator = 'benjamin.peterson'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34672
    keywords = ['patch']
    message_count = 5.0
    messages = ['325319', '325357', '325368', '328695', '328841']
    nosy_count = 4.0
    nosy_names = ['belopolsky', 'benjamin.peterson', 'xiang.zhang', 'p-ganssle']
    pr_nums = ['9288', '9312', '10176']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue34672'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @benjaminp
    Copy link
    Contributor Author

    With the musl C library, one has failures like this:

    ======================================================================
    FAIL: test_strptime (test.test_time.TimeTestCase)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/buildbot/buildarea/3.x.ware-alpine/build/Lib/test/test_time.py", line 273, in test_strptime
        time.strptime(strf_output, format)
    ValueError: time data '' does not match format '%Z'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "/buildbot/buildarea/3.x.ware-alpine/build/Lib/test/test_time.py", line 276, in test_strptime
        (format, strf_output))
    AssertionError: conversion specifier '%Z' failed with '' input.

    The root problem is that time.strptime('%Z', time.gmtime()) won't work—it returns an empty string—even though time.gmtime() will probably have a valid tm_zone field. This is because musl has a safety mechanism where it refuses to process a tm_zone entry unless it produced the string. (See https://git.musl-libc.org/cgit/musl/commit/?id=d78be392e144c338f58ce6a51d82c859126c137d.)

    As a partial workaround, I propose we check whether an incoming time.struct_time instance has an tm_zone member equal to tzname[0] or tzname[1], and place one of those global strings into the C-level tm struct if they do match.

    @benjaminp benjaminp added 3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir labels Sep 14, 2018
    @benjaminp
    Copy link
    Contributor Author

    New changeset 5633c4f by Benjamin Peterson in branch 'master':
    bpo-34672: Try to pass the C library's own timezone strings back to it. (GH-9288)
    5633c4f

    @benjaminp
    Copy link
    Contributor Author

    New changeset b93062b by Benjamin Peterson in branch 'master':
    bpo-34672: Don't pass NULL to gmtime_r. (GH-9312)
    b93062b

    @zhangyangyu
    Copy link
    Member

    New changeset 163eca3 by Xiang Zhang in branch 'master':
    bpo-34672: fix a compiler warning in timemodule.c (GH-10176)
    163eca3

    @abalkin
    Copy link
    Member

    abalkin commented Oct 29, 2018

    It looks like this issue has been fixed by #53534. Can this be closed? Should we backport?

    @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 (EOL) end of life stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants