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

datetime and time tests use non-portable "%4Y" format #90745

Closed
tiran opened this issue Jan 30, 2022 · 3 comments
Closed

datetime and time tests use non-portable "%4Y" format #90745

tiran opened this issue Jan 30, 2022 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@tiran
Copy link
Member

tiran commented Jan 30, 2022

BPO 46587
Nosy @tiran
PRs
  • bpo-46587: Skip tests if strftime does not support glibc extension (GH-31873) #31873
  • 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 = None
    created_at = <Date 2022-01-30.15:14:48.384>
    labels = ['type-bug', 'tests', '3.9', '3.10', '3.11']
    title = 'datetime and time tests use non-portable "%4Y" format'
    updated_at = <Date 2022-03-15.09:41:15.557>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2022-03-15.09:41:15.557>
    actor = 'christian.heimes'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2022-01-30.15:14:48.384>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46587
    keywords = ['patch']
    message_count = 2.0
    messages = ['412157', '415229']
    nosy_count = 1.0
    nosy_names = ['christian.heimes']
    pr_nums = ['31873']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46587'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @tiran
    Copy link
    Member Author

    tiran commented Jan 30, 2022

    Several test cases for datetime and time modules use the non-standard and non-portal width prefix for strftime:

    >>> datetime.date(42, 1, 1).strftime("%4Y")
    '0042'

    According to man strftime(3) https://man7.org/linux/man-pages/man3/strftime.3.html the width field is glibc-specific extension:

    Glibc provides some extensions for conversion specifications.
    (These extensions are not specified in POSIX.1-2001, but a few
    other systems provide similar features.) Between the '%'
    character and the conversion specifier character, an optional
    flag and field width may be specified.

    The width field is not supported by Emscripten, which only implements POSIX.1-2001 compatible date and time formatting: https://github.com/emscripten-core/emscripten/blob/3.1.2/src/library.js#L735

    Python 3.11.0a4+ (heads/main-dirty:b1a3446, Jan 25 2022, 10:19:07) [Clang 14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf1412 on emscripten
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> datetime.date(42, 1, 1).strftime("%4Y")
    '%4Y'

    Also see bpo-13305

    @tiran tiran added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Jan 30, 2022
    @merwok merwok changed the title datetime and time tests use non-portal "%4Y" format datetime and time tests use non-portable "%4Y" format Feb 4, 2022
    @merwok merwok changed the title datetime and time tests use non-portal "%4Y" format datetime and time tests use non-portable "%4Y" format Feb 4, 2022
    @tiran
    Copy link
    Member Author

    tiran commented Mar 15, 2022

    New changeset 2cf7f86 by Christian Heimes in branch 'main':
    bpo-46587: Skip tests if strftime does not support glibc extension (GH-31873)
    2cf7f86

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @kumaraditya303
    Copy link
    Contributor

    Fixed by #31873

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants