| Summary: | strftime on datetime not works on python3. | ||
|---|---|---|---|
| Product: | buildroot | Reporter: | Beyonlo <beyonlo> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | critical | CC: | buildroot |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: |
The .config of buildroot.
The .config of Linux |
||
|
Description
Beyonlo
2014-11-12 12:55:04 UTC
Created attachment 5756 [details]
The .config of buildroot.
Created attachment 5762 [details]
The .config of Linux
buildroot$ git show | grep -i commit commit f21256b86adc88665f6fe1c16672ee7ebf76d6db buildroot$ git describe 2014.08-rc2-42-gf21256b Problem reproduced. One data point is that python3 has the problem, but not python2. Tested with the same uClibc toolchain. Another data point is that it breaks with uClibc (at least the toolchain at http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2014.08.tar.bz2), but works with glibc (CodeSourcery ARM 2014.05). 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? 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. 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. 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. Here is a quick patch that tells Python3 to not use wcsftime() on uClibc, and it fixes the problem for me:
diff --git a/package/python3/python3.mk b/package/python3/python3.mk
index 2c1ef2a..e242835 100644
--- a/package/python3/python3.mk
+++ b/package/python3/python3.mk
@@ -107,6 +107,10 @@ PYTHON3_CONF_ENV += \
ac_cv_file__dev_ptc=yes \
ac_cv_working_tzset=yes
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+PYTHON3_CONF_ENV += ac_cv_func_wcsftime=no
+endif
+
PYTHON3_CONF_OPTS += \
--without-ensurepip \
--without-cxx-main \
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! 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. |