Closed nora-pxh closed 2 years ago
Interesting, this shouldn't be Python related, the locale module should be just a simple wrapper around the C API and I would assume that both utf8
and UTF-8
would work everywhere. Out of curiosity what distribution do you see this on? On both Fedora and Debian en_US.utf8
is the "correct" locale:
$ locale -a | grep en_US
en_US
en_US.iso885915
en_US.utf8
@vojtechtrefny Thank you for your reply! I am sorry that the use of "en_US.UTF-8" is not a good idea. Please confirm the attach file. And I will continue to investigate the reason. libbytesize-test-fail.txt
@vojtechtrefny Thank you for your attention. I know why libbytesize_unittest executed fail. It uses fr_FR.UTF8 to execute libbytesize_unittest.py in tests/libbytesize_unittest.sh.in python3 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1
I did not install the langpacks package of glibc, so it did not support fr_FR.UTF8.
Sorry, I forgot about the french locale in the tests. We should at least provide a better error message in this case, so I'm reopening this issue for tracking that change.
When executing test suite, it displayed the following error message. ERROR: testSubBytes (main.SizeTestCase)
Traceback (most recent call last): File "/home/abuild/rpmbuild/BUILD/libbytesize-2.6/tests/locale_utils.py", line 26, in decorated return test_method(test, *args) File "/home/abuild/rpmbuild/BUILD/libbytesize-2.6/tests/./libbytesize_unittest.py", line 31, in setUp locale.setlocale(locale.LC_ALL, DEFAULT_LOCALE) File "/usr/lib64/python3.9/locale.py", line 610, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting
It seems that python3.9 doesn't recognize "en_US.utf8". DEFAULT_LOCALE should use "en_US.UTF-8" in tests/libbytesize_unittest.py -DEFAULT_LOCALE = "en_US.utf8" +DEFAULT_LOCALE = "en_US.UTF-8"