From: bugzilla at busybox.net <hidden> Date: 2014-11-12 12:55:04
https://bugs.busybox.net/show_bug.cgi?id=7646
Summary: strftime on datetime not works on python3.
Product: buildroot
Version: unspecified
Platform: Other
OS/Version: Linux
Status: NEW
Severity: critical
Priority: P5
Component: Outdated package
AssignedTo: unassigned at buildroot.uclibc.org
ReportedBy: beyonlo at gmail.com
CC: buildroot at uclibc.org
Estimated Hours: 0.0
I set python3 to compile in buildroot and the strftime not works:
# uname -a
Linux buildroot 3.13.5 #1 Wed Nov 12 09:42:52 BRST 2014 armv5tejl GNU/Linux
# python3
Python 3.4.1 (default, Nov 12 2014, 09:22:50)
[GCC 4.4.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
quoted
quoted
from datetime import datetime
datetime.now().strftime("%Y-%m-%d %H:%M:%S")
''
quoted
quoted
As I know, strftime use locale. So I change toolchain to:
"[*] Toolchain has locale support?"
And compile buildroot again. But still not works. The same problem.
However, I tried to do a simple test in C using locale. The strftime works fine
in C.
# uname -a
Linux buildroot 3.13.5 #1 Wed Nov 12 09:42:52 BRST 2014 armv5tejl GNU/Linux
# file test2
test2: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically
linked (uses shared libs), not stripped
# ./test2
Locale is: (null)
Locale is: (null)
Date is: Fri Sep 12 16:34:33 2014
#
This is the c example compiled (using arm cross compile) in the host and put in
the embedded buildroot:
$ cat test2.c
#include <locale.h>
#include <stdio.h>
#include <time.h>
int main ()
{
time_t currtime;
struct tm *timer;
char buffer[80];
time( &currtime );
timer = localtime( &currtime );
printf("Locale is: %s\n", setlocale(LC_ALL, "en_US"));
printf("Locale is: %s\n", setlocale(LC_CTYPE, "en_US.UTF-8"));
strftime(buffer,80,"%c", timer );
printf("Date is: %s\n", buffer);
return(0);
}
Thank you.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #3 from Beyonlo <beyonlo@gmail.com> 2014-11-12 13:18:48 UTC ---
buildroot$ git show | grep -i commit
commit f21256b86adc88665f6fe1c16672ee7ebf76d6db
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #4 from Beyonlo <beyonlo@gmail.com> 2014-11-12 14:33:27 UTC ---
buildroot$ git describe
2014.08-rc2-42-gf21256b
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
From: bugzilla at busybox.net <hidden> Date: 2014-11-12 22:28:23
https://bugs.busybox.net/show_bug.cgi?id=7646
Thomas Petazzoni [off-list ref] changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|Outdated package |Other
--- Comment #5 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2014-11-12 22:28:22 UTC ---
Problem reproduced.
One data point is that python3 has the problem, but not python2. Tested with
the same uClibc toolchain.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #7 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2014-11-12 22:45:49 UTC ---
Hint: since Python 3, Python is using wcsftime() instead of strftime() while
Python 2 was using strftime().
Beyonlo, could you write a C program to test wcsftime() and verify that it
works?
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #8 from Beyonlo <beyonlo@gmail.com> 2014-11-13 10:36:17 UTC ---
Hello, I did the tests with wcsftime. I used this example
http://www.cplusplus.com/reference/cwchar/wcsftime/
$ cat wcsftime_test1.c
/* wcsftime example */
#include <wchar.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
wchar_t buffer [80];
time ( &rawtime );
timeinfo = localtime ( &rawtime );
wcsftime (buffer,80,L"Now it's %I:%M%p.",timeinfo);
wprintf (L"%ls\n",buffer);
return 0;
}
Compiled and run on host:
$ ./wcsftime_test1
Now it's 08:30AM.
Compiled on host (using cross compile - same process used in test2.c) to run on
target (buildroot):
# uname -a
Linux buildroot 3.13.5 #1 Wed Nov 12 09:42:52 BRST 2014 armv5tejl GNU/Linux
# ./wcsftime_test1
#
Ps: Show nothing on buildroot.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #9 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2014-11-13 10:45:43 UTC ---
So wcsftime() is broken in uClibc. It's not a Buildroot bug, but a uClibc bug.
We can workaround it for Python 3 by telling Python explicitly to not use
wcsftime().
We would need to test if uClibc master is affected or not. If it isn't, then we
should backport the patch. It it is, then we should report the bug to upstream
uClibc.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #10 from Beyonlo <beyonlo@gmail.com> 2014-11-13 12:18:13 UTC ---
Hello.
Well, if the quickly solution is by telling Python explicitly to not use
wcsftime(), I think is a good idea. But I don't know if this solution is the
best way.
If you need more tests, please, let me know.
Thank you.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--- Comment #12 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2014-11-13 22:37:39 UTC ---
Patch to workaround the problem in Python 3 sent to Buildroot:
http://lists.busybox.net/pipermail/buildroot/2014-November/112005.html
uClibc bug reproduced with uClibc master, and bug reported to upstream uClibc:
http://lists.uclibc.org/pipermail/uclibc/2014-November/048718.html.
Since I don't expect the uClibc folks to react quickly, I would propose to mark
this bug as fixed once the Python 3 workaround is committed in Buildroot.
Beyonlo, can you test the Buildroot patch for Python 3, and report if it works
for you (it works for me, so I'm pretty sure it's ok, but still). Thanks!
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
From: bugzilla at busybox.net <hidden> Date: 2014-11-14 08:28:57
https://bugs.busybox.net/show_bug.cgi?id=7646
Thomas Petazzoni [off-list ref] changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #13 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2014-11-14 08:28:56 UTC ---
Patch work-arounding the problem for Python 3 has been applied, see
http://git.buildroot.net/buildroot/commit/?id=5ad4ac083276b3504889c39351a56d947f172b5f.
The same problem can occur with other packages, but unfortunately, there's not
much we can do at this point, except waiting for the uClibc folks to react.
Since the original problem related to Python 3 is now fixed, I'm closing this
bug.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.