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

android: test_strptime fails #71116

Closed
xdegaye mannequin opened this issue May 3, 2016 · 16 comments
Closed

android: test_strptime fails #71116

xdegaye mannequin opened this issue May 3, 2016 · 16 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented May 3, 2016

BPO 26929
Nosy @malemburg, @abalkin, @xdegaye, @serhiy-storchaka, @moreati
Files
  • test_output.txt: test results
  • exclude_ymd.patch
  • exclude_ymd_2.patch
  • exclude_ymd_3.patch: Fixes the tuple.
  • 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 = 'https://github.com/xdegaye'
    closed_at = <Date 2016-11-15.18:52:40.976>
    created_at = <Date 2016-05-03.14:11:51.722>
    labels = ['3.7', 'type-bug', 'library']
    title = 'android: test_strptime fails'
    updated_at = <Date 2016-11-15.18:52:40.975>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2016-11-15.18:52:40.975>
    actor = 'xdegaye'
    assignee = 'xdegaye'
    closed = True
    closed_date = <Date 2016-11-15.18:52:40.976>
    closer = 'xdegaye'
    components = ['Library (Lib)']
    creation = <Date 2016-05-03.14:11:51.722>
    creator = 'xdegaye'
    dependencies = []
    files = ['42697', '45406', '45449', '45456']
    hgrepos = []
    issue_num = 26929
    keywords = ['patch']
    message_count = 16.0
    messages = ['264729', '264760', '264761', '264762', '264763', '264765', '264768', '264769', '264786', '264790', '280388', '280389', '280594', '280644', '280647', '280864']
    nosy_count = 6.0
    nosy_names = ['lemburg', 'belopolsky', 'xdegaye', 'python-dev', 'serhiy.storchaka', 'Alex.Willmer']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26929'
    versions = ['Python 3.6', 'Python 3.7']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 3, 2016

    test_strptime fails on an android emulator running an x86 system image at API level 21.

    See the attached test_output.txt file.

    @xdegaye xdegaye mannequin added build The build process and cross-build stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 3, 2016
    @serhiy-storchaka
    Copy link
    Member

    What is the output of following code?

    import datetime
    for i in range(1, 10):
        print(datetime.date(1905, 1, i).strftime('%Y %U %w   %G %V %u'))

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 3, 2016

    root@generic_x86:/data/local/tmp # python
    Python 3.6.0a0 (default:f4c6dab59cd8+, May  3 2016, 21:59:47) 
    [GCC 4.9 20140827 (prerelease)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> for i in range(1, 10):
    ...   print(datetime.date(1905, 1, i).strftime('%Y %U %w   %G %V %u'))
    ... 
    1905 01 0   1904 53 7
    1905 01 1   1905 01 1
    1905 01 2   1905 01 2
    1905 01 3   1905 01 3
    1905 01 4   1905 01 4
    1905 01 5   1905 01 5
    1905 01 6   1905 01 6
    1905 02 0   1905 01 7
    1905 02 1   1905 02 1
    >>>

    @serhiy-storchaka
    Copy link
    Member

    Thanks. And what is the output of following code?

    for i in range(25, 32):
        print(datetime.date(1904, 12, i).strftime('%Y %U %w   %G %V %u'))

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 3, 2016

    >>> for i in range(25, 32):
    ...   print(datetime.date(1904, 12, i).strftime('%Y %U %w   %G %V %u'))
    ... 
    1904 52 0   1904 51 7
    1904 52 1   1904 52 1
    1904 52 2   1904 52 2
    1904 52 3   1904 52 3
    1904 52 4   1904 52 4
    1904 52 5   1904 52 5
    1904 52 6   1904 52 6
    >>>

    @serhiy-storchaka
    Copy link
    Member

    Thus there is a gap between 1904-12-31 and 1905-1-1. This is a bug in strftime() on Android.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 3, 2016

    GNU libc says:

     ‘%V’
          The ISO 8601:1988 week number as a decimal number (range ‘01’
          through ‘53’).  ISO weeks start with Monday and end with
          Sunday.  Week ‘01’ of a year is the first week which has the
          majority of its days in that year; this is equivalent to the
          week containing the year’s first Thursday, and it is also
          equivalent to the week containing January 4.  Week ‘01’ of a
          year can contain days from the previous year.  The week before
          week ‘01’ of a year is the last week (‘52’ or ‘53’) of the
          previous year even if it contains days from the new year.
    
          This format was first standardized by POSIX.2-1992 and by
          ISO C99.
    

    So on 1905-1-1, %V should be 52 instead of 53 as printed by android; is this the only bug ?

    A pretty good test to find such a mistake.

    @serhiy-storchaka
    Copy link
    Member

    There is other bug at the last week of a year:

    import datetime
    for i in range(25, 32):
        print(datetime.date(1906, 12, i).strftime('%Y %U %w   %G %V %u'))
    
    for i in range(1, 10):
        print(datetime.date(1907, 1, i).strftime('%Y %U %w   %G %V %u'))

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 4, 2016

    Here is the result of running on android:

    <script>
    import datetime

    for y in (1904, 1906, 2008, 1917):
        for i in range(25, 32):
            print(datetime.date(y, 12, i).strftime('%Y %U %w   %G %V %u'))
        print()
    
        for i in range(1, 10):
              print(datetime.date(y + 1, 1, i).strftime('%Y %U %w   %G %V %u'))
        print('=====================')
    <script>

    root@generic_x86:/data/local/tmp # python strftime.py
    1904 52 0 1904 51 7
    1904 52 1 1904 52 1
    1904 52 2 1904 52 2
    1904 52 3 1904 52 3
    1904 52 4 1904 52 4
    1904 52 5 1904 52 5
    1904 52 6 1904 52 6

    1905 01 0 1904 53 7
    1905 01 1 1905 01 1
    1905 01 2 1905 01 2
    1905 01 3 1905 01 3
    1905 01 4 1905 01 4
    1905 01 5 1905 01 5
    1905 01 6 1905 01 6
    1905 02 0 1905 01 7
    1905 02 1 1905 02 1
    =====================
    1906 51 2 1906 52 2
    1906 51 3 1906 52 3
    1906 51 4 1906 52 4
    1906 51 5 1906 52 5
    1906 51 6 1906 52 6
    1906 52 0 1906 52 7
    1906 52 1 1907 53 1

    1907 00 2 1907 01 2
    1907 00 3 1907 01 3
    1907 00 4 1907 01 4
    1907 00 5 1907 01 5
    1907 00 6 1907 01 6
    1907 01 0 1907 01 7
    1907 01 1 1907 02 1
    1907 01 2 1907 02 2
    1907 01 3 1907 02 3
    =====================
    2008 51 4 2008 52 4
    2008 51 5 2008 52 5
    2008 51 6 2008 52 6
    2008 52 0 2008 52 7
    2008 52 1 2009 53 1
    2008 52 2 2009 53 2
    2008 52 3 2009 53 3

    2009 00 4 2009 01 4
    2009 00 5 2009 01 5
    2009 00 6 2009 01 6
    2009 01 0 2009 01 7
    2009 01 1 2009 02 1
    2009 01 2 2009 02 2
    2009 01 3 2009 02 3
    2009 01 4 2009 02 4
    2009 01 5 2009 02 5
    =====================
    1917 51 2 1917 52 2
    1917 51 3 1917 52 3
    1917 51 4 1917 52 4
    1917 51 5 1917 52 5
    1917 51 6 1917 52 6
    1917 52 0 1917 52 7
    1917 52 1 1918 53 1

    1918 00 2 1918 01 2
    1918 00 3 1918 01 3
    1918 00 4 1918 01 4
    1918 00 5 1918 01 5
    1918 00 6 1918 01 6
    1918 01 0 1918 01 7
    1918 01 1 1918 02 1
    1918 01 2 1918 02 2
    1918 01 3 1918 02 3
    =====================

    @serhiy-storchaka
    Copy link
    Member

    1904 52 6 1904 52 6
    1905 01 0 1904 53 7
    ^^

    1906 52 0 1906 52 7
    1906 52 1 1907 53 1
    ^^^^

    strftime() on Android incorrectly formats %V or %G for the last or the first incomplete week in a year.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 9, 2016

    Patch attached.

    @xdegaye xdegaye mannequin added 3.7 (EOL) end of life and removed build The build process and cross-build labels Nov 9, 2016
    @xdegaye xdegaye mannequin self-assigned this Nov 9, 2016
    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 9, 2016

    Entered new issue https://code.google.com/p/android/issues/detail?id=227388 on the AOSP issue tracker.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 11, 2016

    New patch following Serhiy comments.

    @serhiy-storchaka
    Copy link
    Member

    exclude_ymd_3.patch LGTM.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 12, 2016

    Thanks Serhiy for your help with this issue.
    I will push this patch with the other Android patches after 3.6 is released.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 15, 2016

    New changeset 3c6e5f83d235 by Xavier de Gaye in branch '3.6':
    Issue bpo-26929: Skip some test_strptime tests failing on Android that
    https://hg.python.org/cpython/rev/3c6e5f83d235

    New changeset 91e0cf7f8e30 by Xavier de Gaye in branch 'default':
    Issue bpo-26929: Merge 3.6
    https://hg.python.org/cpython/rev/91e0cf7f8e30

    @xdegaye xdegaye mannequin closed this as completed Nov 15, 2016
    @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 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant