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
Comments
test_strptime fails on an android emulator running an x86 system image at API level 21. See the attached test_output.txt file. |
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')) |
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
>>> |
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')) |
>>> 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
>>> |
Thus there is a gap between 1904-12-31 and 1905-1-1. This is a bug in strftime() on Android. |
GNU libc says:
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. |
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')) |
Here is the result of running on android: <script> 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 1905 01 0 1904 53 7 1907 00 2 1907 01 2 2009 00 4 2009 01 4 1918 00 2 1918 01 2 |
1904 52 6 1904 52 6 1906 52 0 1906 52 7 strftime() on Android incorrectly formats %V or %G for the last or the first incomplete week in a year. |
Patch attached. |
Entered new issue https://code.google.com/p/android/issues/detail?id=227388 on the AOSP issue tracker. |
New patch following Serhiy comments. |
exclude_ymd_3.patch LGTM. |
Thanks Serhiy for your help with this issue. |
New changeset 3c6e5f83d235 by Xavier de Gaye in branch '3.6': New changeset 91e0cf7f8e30 by Xavier de Gaye in branch 'default': |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: